diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca006-object-test-typing-not-needed.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca006-object-test-typing-not-needed.wiki new file mode 100644 index 00000000..3b8aa70b --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca006-object-test-typing-not-needed.wiki @@ -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= +s: STRING_32 +... +if attached {READABLE_STRING_GENERAL} s as l_s then + l_s.do_something +end + + +=Recommendation= +Remove the specified type in the object test. + +In the example, it can simply be: +if attached s as l_sl then + l_s.do_something +end + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca010-high-complexity-nested-branches-and-loops.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca010-high-complexity-nested-branches-and-loops.wiki new file mode 100644 index 00000000..6b4df92d --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca010-high-complexity-nested-branches-and-loops.wiki @@ -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= +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 + + +=Recommendation= +Encapsulate some of the inner branches or loops into a reusable routine. + +In the example, it can simply be: +if attached a_local then + a_local.do_something +end + + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca011-too-many-arguments.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca011-too-many-arguments.wiki new file mode 100644 index 00000000..6112e49d --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca011-too-many-arguments.wiki @@ -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= +my_document.print (printer_name, paper_size, color_or_not, postscript_level, print_resolution) + + +=Recommendation= +Replace left or right side with something else than the other element. + +In the example, one could write: + +my_document.set_printing_size (paper_size) +my_document.set_color +my_document.print + + +{{SeeAlso | [[CA071 - Self-comparison]]}} + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/index.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/index.wiki index a6f22b71..79d4d5b3 100644 --- a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/index.wiki +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/index.wiki @@ -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