mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-07 07:12:25 +01:00
Author:admin
Date:2014-06-07T00:31:30.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1378 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
[[Property:title|CA006 - Object test typing not needed]]
|
||||
[[Property:link_title|CA006]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|32d6e539-9565-14c2-31b1-5a947a6841f9]]
|
||||
__NOTOC__
|
||||
=Description=
|
||||
In an object test if the expression conforms to the specified type, that type is redundant.
|
||||
|
||||
:{| class="doctable"
|
||||
|-
|
||||
| '''Scope'''
|
||||
| feature
|
||||
|-
|
||||
| '''Status'''
|
||||
| Enabled
|
||||
|-
|
||||
| '''Severity'''
|
||||
| Suggestion
|
||||
|-
|
||||
| '''Applicability'''
|
||||
| All
|
||||
|-
|
||||
| '''Score'''
|
||||
| 40
|
||||
|}
|
||||
|
||||
|
||||
=Example of violation=
|
||||
<e>s: STRING_32
|
||||
...
|
||||
if attached {READABLE_STRING_GENERAL} s as l_s then
|
||||
l_s.do_something
|
||||
end
|
||||
</e>
|
||||
|
||||
=Recommendation=
|
||||
Remove the specified type in the object test.
|
||||
|
||||
In the example, it can simply be:
|
||||
<e>if attached s as l_sl then
|
||||
l_s.do_something
|
||||
end
|
||||
</e>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
[[Property:title|CA010 - High complexity of nested branches and loops]]
|
||||
[[Property:link_title|CA010]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|8b9aeeae-19cb-c0ce-4de9-ba3b0bbd7dca]]
|
||||
__NOTOC__
|
||||
=Description=
|
||||
When the number of nested branches or loops increases, the source code is less readable. This warning is controlled by a complexity threshold preference.
|
||||
|
||||
:{| class="doctable"
|
||||
|-
|
||||
| '''Scope'''
|
||||
| feature
|
||||
|-
|
||||
| '''Status'''
|
||||
| Enabled
|
||||
|-
|
||||
| '''Severity'''
|
||||
| Suggestion
|
||||
|-
|
||||
| '''Applicability'''
|
||||
| All
|
||||
|-
|
||||
| '''Score'''
|
||||
| 60
|
||||
|-
|
||||
| '''Complexity threshold'''
|
||||
| 5
|
||||
|}
|
||||
|
||||
|
||||
=Example of violation=
|
||||
<e>if a > 0 then
|
||||
from j = 1 until j >= s loop
|
||||
from k = 7 until k < 0 loop
|
||||
if enable_check = True then
|
||||
foo (k, j-1)
|
||||
if log_level = 3 then
|
||||
foobar
|
||||
end
|
||||
else
|
||||
bar (2 * j)
|
||||
end
|
||||
k := k - 1
|
||||
end
|
||||
j := j + 1
|
||||
end
|
||||
end
|
||||
</e>
|
||||
|
||||
=Recommendation=
|
||||
Encapsulate some of the inner branches or loops into a reusable routine.
|
||||
|
||||
In the example, it can simply be:
|
||||
<e>if attached a_local then
|
||||
a_local.do_something
|
||||
end
|
||||
</e>
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
[[Property:title|CA011 - Too many arguments]]
|
||||
[[Property:link_title|CA011]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|d25e2dc7-7a95-c13a-bfa2-ceb42a084fa6]]
|
||||
__NOTOC__
|
||||
=Description=
|
||||
A feature that has too many arguments should be avoided since it makes the class interface complicated and it is not easy to use. The feature arguments may include options, which should be considered to be moved to separate features.
|
||||
|
||||
Interfaces of features with a large number of arguments are complicated, in the sense for example that they are hard to remember for the programmer. Often many arguments are of the same type (such as INTEGER). So, in a call, the passed arguments are likely to get mixed up, too, without the compiler detecting it.
|
||||
|
||||
Arguments where in most of the cases the same value is passed--the default value--are called options. As opposed to operands, which are necessary in each feature call, each option should be moved to a separate feature. The features for options can then be called before the operational feature call in order to set (or unset) certain options. If a feature for an option is not called then the class assumes the default value for this option.
|
||||
|
||||
:{| class="doctable"
|
||||
|-
|
||||
| '''Scope'''
|
||||
| Instruction
|
||||
|-
|
||||
| '''Status'''
|
||||
| Enabled
|
||||
|-
|
||||
| '''Severity'''
|
||||
| Warning
|
||||
|-
|
||||
| '''Applicability'''
|
||||
| All
|
||||
|-
|
||||
| '''Score'''
|
||||
| 50
|
||||
|-
|
||||
| '''Arguments threashold'''
|
||||
| 4
|
||||
|}
|
||||
|
||||
|
||||
=Example of violation=
|
||||
<e>my_document.print (printer_name, paper_size, color_or_not, postscript_level, print_resolution)
|
||||
</e>
|
||||
|
||||
=Recommendation=
|
||||
Replace left or right side with something else than the other element.
|
||||
|
||||
In the example, one could write:
|
||||
<e>
|
||||
my_document.set_printing_size (paper_size)
|
||||
my_document.set_color
|
||||
my_document.print
|
||||
</e>
|
||||
|
||||
{{SeeAlso | [[CA071 - Self-comparison]]}}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
[[Property:link_title|Rules]]
|
||||
[[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:
|
||||
For each rule, you will find an English description of the purpose of the rule, followed by a table providing the following information:
|
||||
* Scope: Instruction/
|
||||
* Status: Enabled/Disabled by default
|
||||
* Severity: Warning/Error
|
||||
|
||||
Reference in New Issue
Block a user