mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-06 14:52:03 +01:00
Author:admin
Date:2014-06-05T23:42:12.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1377 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -30,8 +30,10 @@ There are rather exceptional but sometimes useful class designs in which the ext
|
||||
=Example of violation=
|
||||
<e>
|
||||
height: INTEGER
|
||||
-- Height in pixel of Current.
|
||||
|
||||
width: INTEGER
|
||||
-- Width in pixel of Current.
|
||||
do
|
||||
height := height + 10
|
||||
Result := 100 - height
|
||||
@@ -40,12 +42,14 @@ width: INTEGER
|
||||
=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:
|
||||
In the example, one could replace the routine <e>width</e> by an attribute and calling <e>update_width</e> before querying <e>width</e> where <e>update_width</e> would be:
|
||||
<e>update_width
|
||||
-- Update `height' and `width' with ....
|
||||
do
|
||||
height := height + 10
|
||||
width := 100 - height
|
||||
end</e>
|
||||
|
||||
Or you can remove the line <e>height := height + 10</e> from the body of <e>width</e>.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
[[Property:title|CA005 - Useless object test local]]
|
||||
[[Property:link_title|CA005]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|56a54ef0-48e8-b58f-ac2c-09074782b9f7]]
|
||||
__NOTOC__
|
||||
=Description=
|
||||
For local variables and feature arguments it is unnecessary to use an object test to check their attachment status.
|
||||
|
||||
:{| class="doctable"
|
||||
|-
|
||||
| '''Scope'''
|
||||
| feature
|
||||
|-
|
||||
| '''Status'''
|
||||
| Enabled
|
||||
|-
|
||||
| '''Severity'''
|
||||
| Suggestion
|
||||
|-
|
||||
| '''Applicability'''
|
||||
| All
|
||||
|-
|
||||
| '''Score'''
|
||||
| 40
|
||||
|}
|
||||
|
||||
|
||||
=Example of violation=
|
||||
<e>if attached a_local as another_local then
|
||||
another_local.do_something
|
||||
end
|
||||
</e>
|
||||
|
||||
=Recommendation=
|
||||
Remove the object test local, or replace the object test and use a comparison to <e>Void</e>.
|
||||
|
||||
In the example, it can simply be:
|
||||
<e>if attached a_local then
|
||||
a_local.do_something
|
||||
end
|
||||
</e>
|
||||
|
||||
or
|
||||
|
||||
<e>if a_local /= Void then
|
||||
a_local.do_something
|
||||
end
|
||||
</e>
|
||||
|
||||
Reference in New Issue
Block a user