From 5898cd4432c754d39f06a7018e02dfcb882d6662 Mon Sep 17 00:00:00 2001 From: jfiat Date: Thu, 5 Jun 2014 18:22:05 +0000 Subject: [PATCH] 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 --- documentation/current/_templates/SeeAlso.tpl | 9 +++- .../ca001-self-assignment.wiki | 13 +++-- .../ca002-unused-argument.wiki | 37 ++++++++++++++ .../ca003-feature-never-called.wiki | 33 ++++++++++++ .../ca004-command-query-separation.wiki | 51 +++++++++++++++++++ .../ca071-self-comparison.wiki | 16 +++--- .../eiffel-inspector-rules/index.wiki | 10 ++-- 7 files changed, 152 insertions(+), 17 deletions(-) create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca002-unused-argument.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca003-feature-never-called.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca004-command-query-separation.wiki diff --git a/documentation/current/_templates/SeeAlso.tpl b/documentation/current/_templates/SeeAlso.tpl index d923096e..10e44d86 100644 --- a/documentation/current/_templates/SeeAlso.tpl +++ b/documentation/current/_templates/SeeAlso.tpl @@ -1 +1,8 @@ -

[[Image:LogoInformation|24px]] '''See Also: '''{{{1}}}

+
+ + + + + +
[[Image:LogoInformation|24px]]'''See Also: '''{{{1}}}
+
diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca001-self-assignment.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca001-self-assignment.wiki index 03dafc75..2b41c95e 100644 --- a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca001-self-assignment.wiki +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca001-self-assignment.wiki @@ -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= a := a -=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 '''a''' by something else. {{SeeAlso | [[CA071 - Self-comparison]]}} diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca002-unused-argument.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca002-unused-argument.wiki new file mode 100644 index 00000000..83e04b8f --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca002-unused-argument.wiki @@ -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= +square (x, y: INTEGER): INTEGER + do + Result := x * 2 + end + +=Recommendation= +Remove argument and update callers. + +In the example, remove the argument '''y''' from the argument list. + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca003-feature-never-called.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca003-feature-never-called.wiki new file mode 100644 index 00000000..b7c2d726 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca003-feature-never-called.wiki @@ -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. + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca004-command-query-separation.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca004-command-query-separation.wiki new file mode 100644 index 00000000..7c72b60a --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca004-command-query-separation.wiki @@ -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= + +height: INTEGER + +width: INTEGER + do + height := height + 10 + Result := 100 - height + end + +=Recommendation= +Ensures that no query changes the state of the current object. + +In the example, one could replace the call to width by a call to update_width followed by a call to width where update_width would be: +update_width + do + height := height + 10 + width := 100 - height + end + + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca071-self-comparison.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca071-self-comparison.wiki index 47d621c4..12569f37 100644 --- a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca071-self-comparison.wiki +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca071-self-comparison.wiki @@ -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= if a >= a then ... end -=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 '''a''' by something else. {{SeeAlso | [[CA001 - Self Assignment]]}} 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 ba48e4b5..a6f22b71 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 @@ -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.