Author:admin

Date:2014-06-05T18:22:05.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1376 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
jfiat
2014-06-05 18:22:05 +00:00
parent d42e808ca1
commit 5898cd4432
7 changed files with 152 additions and 17 deletions

View File

@@ -1 +1,8 @@
<p style="margin-left: 10px; margin-right: 50px; border: 1px solid #0a427d; padding: 10px; background-color: #eef7fb; color: black;">[[Image:LogoInformation|24px]] '''See Also: '''{{{1}}}</p>
<div style="margin:10px; border: 1px solid #0a427d; padding: 5px; background-color: #eef7fb; color: black;">
<table>
<tr>
<td style="vertical-align:top;">[[Image:LogoInformation|24px]]</td>
<td>'''See Also: '''{{{1}}}</td>
</tr>
</table>
</div>

View File

@@ -10,8 +10,8 @@ Assigning a variable to itself is a meaningless instruction due to a typing erro
| '''Scope'''
| Instruction
|-
| '''Enabled'''
| Yes
| '''Status'''
| Enabled
|-
| '''Severity'''
| Warning
@@ -23,12 +23,15 @@ Assigning a variable to itself is a meaningless instruction due to a typing erro
| 70
|}
=Example=
=Example of violation=
<e>a := a
</e>
=Suggested Fix=
Replace source or target with proper expression.
=Recommendation=
Replace left or right side with something else than the other element.
In the example, replace one of the '''<e>a</e>''' by something else.
{{SeeAlso | [[CA071 - Self-comparison]]}}

View File

@@ -0,0 +1,37 @@
[[Property:title|CA002 - Unused argument]]
[[Property:link_title|CA002]]
[[Property:weight|0]]
[[Property:uuid|fc2cf9c2-76b5-5d2f-4d60-c8dfbc677427]]
__NOTOC__
=Description=
A feature should only have arguments which are actually needed and used in the computation.
:{| class="doctable"
|-
| '''Scope'''
| Feature
|-
| '''Status'''
| Disabled
|-
| '''Severity'''
| Warning
|-
| '''Applicability'''
| All
|-
| '''Score'''
| 40
|}
=Example of violation=
<e>square (x, y: INTEGER): INTEGER
do
Result := x * 2
end</e>
=Recommendation=
Remove argument and update callers.
In the example, remove the argument '''<e>y</e>''' from the argument list.

View File

@@ -0,0 +1,33 @@
[[Property:title|CA003 - Feature never called]]
[[Property:link_title|CA003]]
[[Property:weight|0]]
[[Property:uuid|21e52517-beb3-9843-8c39-dd0c8e11e945]]
__NOTOC__
=Description=
There is no use for a feature that is never called by any class (including the one where it is defined).
:{| class="doctable"
|-
| '''Scope'''
| System
|-
| '''Status'''
| Disabled
|-
| '''Severity'''
| Warning
|-
| '''Applicability'''
| Non-library
|-
| '''Score'''
| 40
|}
=Example of violation=
A feature defined in the system but never called.
=Recommendation=
Remove feature from the system.

View File

@@ -0,0 +1,51 @@
[[Property:title|CA004 - Command-Query Separation]]
[[Property:link_title|CA004]]
[[Property:weight|0]]
[[Property:uuid|7d58b7d3-e7e5-d3ec-83c8-84fca33bf638]]
__NOTOC__
=Description=
A function should never change the state of an object. A function containing a procedure call, an assignment to an attribute, or creating an attribute is a strong indication that this principle is violated. This rule applies exactly in these three cases.
There are rather exceptional but sometimes useful class designs in which the externally visible state of an object (i. e. the values of exported queries) does not change even though the function contains a rule-violating instruction.
:{| class="doctable"
|-
| '''Scope'''
| Class
|-
| '''Status'''
| Enabled
|-
| '''Severity'''
| Warning
|-
| '''Applicability'''
| All
|-
| '''Score'''
| 60
|}
=Example of violation=
<e>
height: INTEGER
width: INTEGER
do
height := height + 10
Result := 100 - height
end</e>
=Recommendation=
Ensures that no query changes the state of the current object.
In the example, one could replace the call to <e>width</e> by a call to <e>update_width</e> followed by a call to <e>width</e> where <e>update_width</e> would be:
<e>update_width
do
height := height + 10
width := 100 - height
end</e>

View File

@@ -7,14 +7,11 @@ __NOTOC__
An expression comparing a variable to itself always evaluates to the same boolean value. The comparison is thus redundant. In an Until expression it may lead to non-termination. Usually it is a typing error.
:{| class="doctable"
|-
! Property
! Value
|-
| '''Scope'''
| Instruction
|-
| '''Enabled'''
| Yes
| '''Status'''
| Enabled
|-
| '''Severity'''
| Warning
@@ -26,13 +23,16 @@ An expression comparing a variable to itself always evaluates to the same boolea
| 70
|}
=Example=
=Example of violation=
<e>if a >= a then
...
end</e>
=Suggested Fix=
Replace left or right-hand side of comparison with proper expression.
=Recommendation=
Replace left or right side of comparison with something else than the other element.
In the example, replace '''<e>a</e>''' by something else.
{{SeeAlso | [[CA001 - Self Assignment]]}}

View File

@@ -3,7 +3,11 @@
[[Property:weight|15]]
[[Property:uuid|109ca62a-212d-8a85-eea8-ddf0f89177a1]]
For each rules, you will find an English description of the purpose of the rule, followed by a table providing the following information:
* scope:
* status: Enabled/Disabled by default
*
* Scope: Instruction/
* Status: Enabled/Disabled by default
* Severity: Warning/Error
* Applicability: All
* Score: Value used to
In addition you will find an example for a rule violation as well as a suggested fix when available.