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
This commit is contained in:
jfiat
2014-06-17 12:58:13 +00:00
parent f77c35d8ea
commit 1da2dd1bf7
11 changed files with 439 additions and 6 deletions

View File

@@ -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 <code>ISE_DBG_PORTNUM</code> 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 <eiffel>{RT_DEBUGGER}.rt_workbench_wait_for_debugger (a_port_number: INTEGER)</eiffel> 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 <code>ISE_DBG_PORTNUM</code> 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 <eiffel>{RT_DEBUGGER}.rt_workbench_wait_for_debugger (a_port_number: INTEGER)</eiffel> 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 <code>Execution->Attach Debuggee</code> 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.

View File

@@ -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 <e>x.make</e> instead of <e>create x.make</e>, 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=
<e>class TEST
create
make
feature -- Initialization
make
-- Initialize Current
do
end
update
do
end
end
</e>
=Recommendation=
Make sure to export the creation procedure to NONE.
In the example, add the export to NONE after the feature clause:
<e>class TEST
create
make
feature {NONE} -- Initialization
make
-- Initialize Current
do
end
feature -- Initialization
update
do
end
end
</e>

View File

@@ -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=
<e>if x and y then
end
do_something_else
</e>
=Recommendation=
Remove the useless conditional.
In the example, simply keep:
<e>
do_something_else</e>

View File

@@ -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=
<e>
local
x, y: INTEGER
do
x := 3
y := some_height_query
x := some_width_query
...
end
</e>
=Recommendation=
Remove the assignment without effect.
In the example, remove the first assignment to <e>x</e>:
<e>
local
x, y: INTEGER
do
y := some_height_query
x := some_width_query
...
end
</e>
{{SeeAlso | [[CA071 - Self-comparison]]}}

View File

@@ -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=
<e>if (z > 3) then
z := (z - 5)
end
</e>
=Recommendation=
Remove the parenthesis that are not needed.
In the example, it simply becomes:
<e>if z > 3 then
z := z - 5
end
</e>

View File

@@ -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 <e>ITERABLE</e> with a traditional <e>from ... until ... loop ...end</e> 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=
<e>from
list.start
until
list.after
loop
...
list.forth
end
</e>
=Recommendation=
Replace with an across loop. In the example it becomes:
<e>across list as l loop
...
end
</e>

View File

@@ -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=
<e>f (a: INTEGER b: INTEGER)
do
end
</e>
=Recommendation=
Add the missing semicolons between arguments. In the example, it becomes:
<e>f (a: INTEGER; b: INTEGER)
do
end
</e>

View File

@@ -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 <e>and then</e> boolean operator.
:{| class="doctable"
|-
| '''Scope'''
| Instruction
|-
| '''Status'''
| Enabled
|-
| '''Severity'''
| Suggestion
|-
| '''Applicability'''
| All
|-
| '''Score'''
| 40
|}
=Example of violation=
<e>if user /= Void then
if user.age >= 18 then
...
end
end
</e>
=Recommendation=
Combine the nested if instructions using <e>and then</e>. In the example, it becomes:
<e>if user /= Void and then user.age >= 18 then
...
end</e>

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.