From 1da2dd1bf75a33074c8e1c9bc6a93a853b53804f Mon Sep 17 00:00:00 2001 From: jfiat Date: Tue, 17 Jun 2014 12:58:13 +0000 Subject: [PATCH] Author:admin Date:2014-06-12T22:36:54.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1380 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../attach-application.wiki | 14 +++-- .../ca013-exported-creation-procedure.wiki | 61 +++++++++++++++++++ .../ca017-empty-conditional.wiki | 40 ++++++++++++ ...20-variable-not-read-after-assignment.wiki | 54 ++++++++++++++++ .../ca023-unneeded-parentheses.wiki | 43 +++++++++++++ .../ca024-use-across-loop.wiki | 45 ++++++++++++++ .../ca025-use-semicolons.wiki | 40 ++++++++++++ .../ca028-combine-two-if-instructions.wiki | 39 ++++++++++++ .../ca032-long-routine-implementation.wiki | 35 +++++++++++ .../ca033-large-class.wiki | 39 ++++++++++++ .../ca034-high-npath-complexity.wiki | 35 +++++++++++ 11 files changed, 439 insertions(+), 6 deletions(-) create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca013-exported-creation-procedure.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca017-empty-conditional.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca020-variable-not-read-after-assignment.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca023-unneeded-parentheses.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca024-use-across-loop.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca025-use-semicolons.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca028-combine-two-if-instructions.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca032-long-routine-implementation.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca033-large-class.wiki create mode 100644 documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca034-high-npath-complexity.wiki diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/debugger/execution-commands/attach-application.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/debugger/execution-commands/attach-application.wiki index cd6d0a80..3898ac56 100644 --- a/documentation/current/eiffelstudio/eiffelstudio-reference/debugger/execution-commands/attach-application.wiki +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/debugger/execution-commands/attach-application.wiki @@ -7,17 +7,19 @@ However for specific needs (such as server development), you might want to start Requirements: * The application should be compiled in workbench mode. -* EiffelStudio should be open on the project which was used to compile the application. +* EiffelStudio should be opened on the project used to compile the application. How to make it work? -* On the application side, at some point you will need to provide a port number, and at that point the application will wait for the debugger. +* The application execution will wait for the debugger to connect on a specific port number (given by the user). -To speciffy the port number you have two possibilities: -* setting the ISE_DBG_PORTNUM environment variable to a specific port number. When the environment variable is set, the application after starting will immediately put itself in a mode where it will wait for EiffelStudio to attach the process -* calling {RT_DEBUGGER}.rt_workbench_wait_for_debugger (a_port_number: INTEGER) from the program itself. In this case, the program will put itself in a mode where it will wait for EiffelStudio to attach the process when you call this routine. +There are 2 ways to provide this port number: +* setting the ISE_DBG_PORTNUM environment variable to a specific port number. When this environment variable is set, the application, right after starting, will immediately wait for EiffelStudio to attach the process +* calling {RT_DEBUGGER}.rt_workbench_wait_for_debugger (a_port_number: INTEGER) from the application code. In this case, when this routine is executed, the program will wait for EiffelStudio to attach the process. +In both case, the execution will wait about 10 seconds, if EiffelStudio does not connect before, the execution will continue. +It is possible to use any available port number, for that make sure your machine does not already use the port number you choose, and that the application is authorized to open that port (for instance port 10505 is often available). To attach the process from EiffelStudio, follow the menu path Execution->Attach Debuggee and provide the same port number as specified above. (Note that you can add the associated command to the execution tool bar.) -At this point EiffelStudio is able to debug the application just as if the application had been launched by EiffelStudio. +Once EiffelStudio attached the execution, it is able to debug the application just as if the application had been launched by EiffelStudio. diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca013-exported-creation-procedure.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca013-exported-creation-procedure.wiki new file mode 100644 index 00000000..7d197c50 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca013-exported-creation-procedure.wiki @@ -0,0 +1,61 @@ +[[Property:title|CA013 - Exported creation procedure]] +[[Property:link_title|CA013]] +[[Property:weight|0]] +[[Property:uuid|26455914-3b04-cacc-67bb-cd8e083ce947]] +__NOTOC__ +=Description= +If acreation procedure is exported then it may be called by clients after the object has been created. Usually, this is not intended. A client might, for example, by accident call x.make instead of create x.make, possibly causing a class invariant or postcondition to not hold anymore. + +:{| class="doctable" +|- +| '''Scope''' +| class +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Warning +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 50 +|} + + +=Example of violation= +class TEST +create + make +feature -- Initialization + make + -- Initialize Current + do + end + update + do + end +end + + +=Recommendation= +Make sure to export the creation procedure to NONE. + +In the example, add the export to NONE after the feature clause: +class TEST +create + make +feature {NONE} -- Initialization + make + -- Initialize Current + do + end +feature -- Initialization + update + do + end +end + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca017-empty-conditional.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca017-empty-conditional.wiki new file mode 100644 index 00000000..70945961 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca017-empty-conditional.wiki @@ -0,0 +1,40 @@ +[[Property:title|CA017 - Empty conditional]] +[[Property:link_title|CA017]] +[[Property:weight|0]] +[[Property:uuid|4616cef3-6eaf-1ab6-6071-d629443dfbf0]] +__NOTOC__ +=Description= +An empty conditional instruction is useless and should be removed. + +:{| class="doctable" +|- +| '''Scope''' +| Instruction +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Warning +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 50 +|} + + +=Example of violation= +if x and y then +end +do_something_else + + +=Recommendation= +Remove the useless conditional. +In the example, simply keep: + + +do_something_else + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca020-variable-not-read-after-assignment.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca020-variable-not-read-after-assignment.wiki new file mode 100644 index 00000000..f8f0a397 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca020-variable-not-read-after-assignment.wiki @@ -0,0 +1,54 @@ +[[Property:title|CA020 - Variable not read after assignment]] +[[Property:link_title|CA020]] +[[Property:weight|0]] +[[Property:uuid|8de22b33-be9c-b946-ce39-709cf42f01c5]] +__NOTOC__ +=Description= +An assignment to a local variable has not effect at all if the variable is not read after the assignment, or reassigned. +{| class="doctable" +|- +| '''Scope''' +| Instruction +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Warning +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 70 +|} + + +=Example of violation= + +local + x, y: INTEGER +do + x := 3 + y := some_height_query + x := some_width_query + ... +end + + +=Recommendation= +Remove the assignment without effect. + +In the example, remove the first assignment to x: + +local + x, y: INTEGER +do + y := some_height_query + x := some_width_query + ... +end + + +{{SeeAlso | [[CA071 - Self-comparison]]}} + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca023-unneeded-parentheses.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca023-unneeded-parentheses.wiki new file mode 100644 index 00000000..77e39edc --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca023-unneeded-parentheses.wiki @@ -0,0 +1,43 @@ +[[Property:title|CA023 - Unneeded parentheses]] +[[Property:link_title|CA023]] +[[Property:weight|0]] +[[Property:uuid|9af7b35f-7e74-2bd1-8680-b59ab81d6791]] +__NOTOC__ +=Description= +Parentheses that are not needed should be removed. This helps enforcing a consistent coding style +:{| class="doctable" +|- +| '''Scope''' +| Instruction +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Suggestion +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 30 +|} + + +=Example of violation= +if (z > 3) then + z := (z - 5) +end + + +=Recommendation= +Remove the parenthesis that are not needed. + +In the example, it simply becomes: +if z > 3 then + z := z - 5 +end + + + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca024-use-across-loop.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca024-use-across-loop.wiki new file mode 100644 index 00000000..9f04aa57 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca024-use-across-loop.wiki @@ -0,0 +1,45 @@ +[[Property:title|CA024 - Use across loop]] +[[Property:link_title|CA024]] +[[Property:weight|0]] +[[Property:uuid|d24ebe87-3a57-105e-7900-e77608cac47c]] +__NOTOC__ +=Description= +When iterating on an instance of ITERABLE with a traditional from ... until ... loop ...end from beginning to end you should use an across loop to avoid forgetting to advance the cursor. +:{| class="doctable" +|- +| '''Scope''' +| Instruction +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Suggestion +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 30 +|} + + +=Example of violation= +from + list.start +until + list.after +loop + ... + list.forth +end + + +=Recommendation= +Replace with an across loop. In the example it becomes: +across list as l loop + ... +end + + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca025-use-semicolons.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca025-use-semicolons.wiki new file mode 100644 index 00000000..b905bfc1 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca025-use-semicolons.wiki @@ -0,0 +1,40 @@ +[[Property:title|CA025 - Use semicolons]] +[[Property:link_title|CA025]] +[[Property:weight|0]] +[[Property:uuid|41ec250b-3967-797e-9843-59eab795f391]] +__NOTOC__ +=Description= +Routine arguments should be separated with semicolons. Although this is optional, it is not a recommended style to not put semicolons. +:{| class="doctable" +|- +| '''Scope''' +| feature +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Suggestion +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 40 +|} + + +=Example of violation= +f (a: INTEGER b: INTEGER) + do + end + + +=Recommendation= +Add the missing semicolons between arguments. In the example, it becomes: +f (a: INTEGER; b: INTEGER) + do + end + + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca028-combine-two-if-instructions.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca028-combine-two-if-instructions.wiki new file mode 100644 index 00000000..73084090 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca028-combine-two-if-instructions.wiki @@ -0,0 +1,39 @@ +[[Property:title|CA028 - Combine two if instructions]] +[[Property:link_title|CA028]] +[[Property:weight|0]] +[[Property:uuid|47b9a80f-16d7-82c7-7d23-19f740fb2978]] +__NOTOC__ +=Description= +Two nested instructions, both not having an else clause, could be combined into a single if instruction using the and then boolean operator. +:{| class="doctable" +|- +| '''Scope''' +| Instruction +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Suggestion +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 40 +|} + +=Example of violation= +if user /= Void then + if user.age >= 18 then + ... + end +end + + +=Recommendation= +Combine the nested if instructions using and then. In the example, it becomes: +if user /= Void and then user.age >= 18 then + ... +end + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca032-long-routine-implementation.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca032-long-routine-implementation.wiki new file mode 100644 index 00000000..ae146c5c --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca032-long-routine-implementation.wiki @@ -0,0 +1,35 @@ +[[Property:title|CA032 - Long routine implementation]] +[[Property:link_title|CA032]] +[[Property:weight|0]] +[[Property:uuid|9edb21ce-ab0c-69ea-c494-a39dc7a26b15]] +__NOTOC__ +=Description= +A routine implementation that contains many instructions should be shortened to make it easier to understand. +:{| class="doctable" +|- +| '''Scope''' +| feature +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Warning +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 70 +|- +| '''Instructions threshold''' +| 70 +|} + + +=Example of violation= +A routine with many lines of code. + +=Recommendation= +Decompose the routine by creating new routines that will be used in the original long routine. + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca033-large-class.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca033-large-class.wiki new file mode 100644 index 00000000..af3d69d5 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca033-large-class.wiki @@ -0,0 +1,39 @@ +[[Property:title|CA033 - Large class]] +[[Property:link_title|CA033]] +[[Property:weight|0]] +[[Property:uuid|93aaff4c-3406-311e-3760-facad969131e]] +__NOTOC__ +=Description= +A large class declaration might not be ideal for readability. Consider moving out features that are not really part of the class. +:{| class="doctable" +|- +| '''Scope''' +| class +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Warning +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 60 +|- +| '''Features threshold''' +| 20 +|- +| '''Instructions threshold''' +| 300 +|} + + +=Example of violation= +A class with too many routines or too many instructions. + +=Recommendation= +Refactor the class to reduce the number of routines or instructions. + + diff --git a/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca034-high-npath-complexity.wiki b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca034-high-npath-complexity.wiki new file mode 100644 index 00000000..4dfe09b6 --- /dev/null +++ b/documentation/current/eiffelstudio/eiffelstudio-reference/eiffel-inspector/eiffel-inspector-rules/ca034-high-npath-complexity.wiki @@ -0,0 +1,35 @@ +[[Property:title|CA034 - High NPATH complexity]] +[[Property:link_title|CA034]] +[[Property:weight|0]] +[[Property:uuid|f6ffe1e0-2b46-66db-60de-0cdd5c42f453]] +__NOTOC__ +=Description= +NPATH is the number of acyclic execution paths through a routine. A routine's NPATH complexity should not be too high. In order to reduce the NPATH complexity one can move some functionality to separate routines. +:{| class="doctable" +|- +| '''Scope''' +| Feature +|- +| '''Status''' +| Enabled +|- +| '''Severity''' +| Warning +|- +| '''Applicability''' +| All +|- +| '''Score''' +| 60 +|- +| '''NPATH complexity threshold''' +| 200 +|} + + +=Example of violation= + +=Recommendation= +Reduce complexity of routine by refactoring parts of the routine into their own routines. + +