mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2026-04-05 09:39:31 +02:00
Author:admin
Date:2014-06-04T00:14:45.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1371 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
[[Property:title|Eiffel Inspector - Analyzing Results]]
|
||||
[[Property:link_title|Analyzing Results]]
|
||||
[[Property:weight|-13]]
|
||||
[[Property:uuid|e4670791-7885-b9a0-6a1c-0d9611eb5f5d]]
|
||||
= Sorting and Filtering =
|
||||
|
||||
The list of rule violations can be sorted by any column by clicking on its header. Click it again to switch the sorting direction. You can hide and show errors, warnings, suggestions, and hints by clicking the corresponding toggle buttons in the middle of the toolbar. Typing in the text field on the right side of the panel toolbar filters the results. The filter takes into consideration the title, the ID, the affected class, and the description of the rule. It is a live filter that filters while you are typing. Press the button on the right of the text field to clear the filter and display again all violations.
|
||||
[img_assist|nid=2645|title=The results of code analysis as a list of rule violations (example)|desc=|link=node|align=center|width=978|height=361]
|
||||
|
||||
= Navigating Through the Results =
|
||||
|
||||
In the list of rule violations, formatted elements like classes and features are clickable and draggable like anywhere else. In order to navigate to a specific rule violation just double-click the corresponding row. The corresponding class will be opened (if needed) and the cursor will jump to the exact location of the rule violation (some violations do not have an exact location because they refer to a whole class). You can also navigate through the results using the '''Go to next rule violation''' and '''Go to previous rule violation''' buttons on the right side of the panel toolbar.
|
||||
|
||||
= Fixing Rule Violations =
|
||||
|
||||
[img_assist|nid=2654|title=Fixing a rule violation.|desc=|link=node|align=center|width=484|height=79]
|
||||
Some violations provide automatic fixing. Right-clicking the corresponding row in the tool panel opens a context menu where you can choose from one or more possible fixes. When you click on ''Fix: ...'' the source code will be adapted and the project will be recompiled.
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
[[Property:title|Eiffel Inspector - Customization]]
|
||||
[[Property:link_title|Customization]]
|
||||
[[Property:weight|-12]]
|
||||
[[Property:uuid|ed86093e-fed0-04b8-6fd4-b05d5de849fc]]
|
||||
= General Preferences =
|
||||
|
||||
The ''Preferences'' button in the toolbar opens a dialog containing all preferences for the Eiffel Inspector. There you can enable and disable all rules of a certain severity, you can choose colors for the results, and there are many preferences that control the behavior of individual rules.
|
||||
|
||||
[img_assist|nid=2651|title=Preferences|desc=|link=node|align=center|width=640|height=460]
|
||||
|
||||
= Rule-specific Preferences =
|
||||
|
||||
The rule-specific preferences are located in the ''Rules'' subfolder. Two preferences can be found for every rule: ''Enabled/disabled'' and the ''severity score''. Some rules have additional integer or boolean preferences like thresholds.
|
||||
|
||||
[img_assist|nid=2652|title=Rule-specific Preferences|desc=|link=node|align=center|width=572|height=268]
|
||||
|
||||
= Exporting and Importing Preference Profiles =
|
||||
|
||||
Using the buttons in the preferences dialog one can export these preferences to an XML file or import them. This can be used for creating profiles that stretch across multiple machines. Just set the desired preferences on one machine, export them to a file, distribute this file, and import it.
|
||||
|
||||
{{note| The Eiffel Inspector preferences are separate from the general EiffelStudio preferences. Pressing ''Restore Defaults'', ''Import ...'', or ''Export ...'' ''only'' affects preferences for the Eiffel Inspector.''}}
|
||||
|
||||
= Class Options =
|
||||
|
||||
There are cases in which you might want to customize the Eiffel Inspector for ''parts of your code'' only. The Eiffel Inspector provides a way to set options ''per class''. You can exclude a class from being checked by certain rules. Also you can declare a class to be a ''library'' or a ''non-library'' class. All class-wide options for the Eiffel Inspector are set in the ''note clause'' (after the <e>note</e> keyword).
|
||||
|
||||
== Library and Non-Library Classes ==
|
||||
|
||||
If the programmer uses the default values then a rule checks all classes. But a rule can be defined (hard-coded) not to check either ''library'' or ''non-library'' classes. How does the Eiffel Inspector now know which classes are ''library'' classes and which classes are ''non-library'' classes? This is defined by the user. If, for a certain class, the user does ''not'' define anything then the class will be analyzed in every case. Only if the user declares a class to be a ''library'' class then this class will not be checked by a rule that has disabled checking library classes. The same goes for classes that are declared as ''non-library''.
|
||||
|
||||
* To declare a class to be a ''library'' class add <e>ca_library : "true"</e> to the (top or bottom) indexing clause.
|
||||
* To declare a class to be a ''non-library'' class add <e>ca_library : "false"</e> to the (top or bottom) indexing clause.
|
||||
|
||||
<e>note
|
||||
ca_library: true
|
||||
class TEST
|
||||
end
|
||||
</e>
|
||||
|
||||
== Classes Ignored by Rules ==
|
||||
|
||||
You can declare a class to be ''ignored'' by certain rules, which is equivalent to saying that some rules shall be ''disabled'' for a class.
|
||||
|
||||
To let a class be ignored by certain rules, add the <e>ca_ignoredby</e> tag to the (top or bottom) note clause. Then put all the relevant ''rule IDs'' separated by commas in the content. It may look like this:
|
||||
|
||||
<e>note
|
||||
ca_ignoredby : "CA005, CA092"
|
||||
class TEST
|
||||
end</e>
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
[[Property:title|Eiffel Inspector - Getting Started]]
|
||||
[[Property:link_title|Getting Started]]
|
||||
[[Property:weight|-15]]
|
||||
[[Property:uuid|81ae12fd-f643-c5ba-825c-7750929f6978]]
|
||||
==Eiffel Inspector Tool==
|
||||
After opening an existing project with EiffelStudio, go to View->Tools->Eiffel Inspector to show the tool. It will look like this:
|
||||
|
||||
[img_assist|nid=2643|title=Eiffel Inspector - Tool Panel|desc=The Inspector Eiffel tool panel before the analysis.|link=node|align=center|width=1119|height=324]
|
||||
|
||||
== A Simple Analysis ==
|
||||
|
||||
Press the '''Analyze System''' button. If needed, the system will be compiled now. A successful compilation is required for the Eiffel Inspector to run. After a successful compilation the analysis will start and will check all classes of your system. The status bar shows the progress by displaying the class currently being analyzed. As soon as the analysis is complete, results will show up in the panel as a list of ''rule violations''.
|
||||
|
||||
[img_assist|nid=2645|title=Eiffel Inspector - Simple Analysis|desc=The results of code analysis as a list of rule violations (example).|link=node|align=center|width=978|height=361]
|
||||
|
||||
A double-click on a row will update the EiffelStudio editor to go to the position in the code where the issue lies. You may expand the row to see more details.
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
[[Property:title|CA001 - Self Assignment]]
|
||||
[[Property:link_title|CA001]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|d98b7fb8-37a1-05b3-a58f-baacefd5dce6]]
|
||||
__NOTOC__
|
||||
=Description=
|
||||
Assigning a variable to itself is a meaningless instruction due to a typing error. Most probably, one of the two variable names was misspelled. One example among many others: the programmer wanted to assign a local variable to a class attribute and used one of the variable names twice.
|
||||
|
||||
=Details=
|
||||
*Scope: Instruction
|
||||
*Enabled: Yes
|
||||
*Severity: Warning
|
||||
*Applicability: All
|
||||
*Score: 70
|
||||
|
||||
=Example=
|
||||
<e>a := a</e>
|
||||
|
||||
=Suggested Fix=
|
||||
Replace source or target with proper expression.
|
||||
|
||||
{{SeeAlso | [[CA071 - Self-comparison]]}}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
[[Property:title|CA071 - Self-comparison]]
|
||||
[[Property:link_title|CA071]]
|
||||
[[Property:weight|0]]
|
||||
[[Property:uuid|02a649b3-0e4e-6fdf-388d-c411a06fc787]]
|
||||
__NOTOC__
|
||||
=Description=
|
||||
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.
|
||||
|
||||
=Details=
|
||||
*Scope: Instruction
|
||||
*Enabled: Yes
|
||||
*Severity: Warning
|
||||
*Applicability: All
|
||||
*Score: 70
|
||||
|
||||
=Example=
|
||||
<e>if a >= a then
|
||||
...
|
||||
end</e>
|
||||
|
||||
=Suggested Fix=
|
||||
Replace left or right-hand side of comparison with proper expression.
|
||||
|
||||
{{SeeAlso | [[CA001 - Self Assignment]]}}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[[Property:title|Eiffel Inspector - Rules]]
|
||||
[[Property:link_title|Rules]]
|
||||
[[Property:weight|15]]
|
||||
[[Property:uuid|109ca62a-212d-8a85-eea8-ddf0f89177a1]]
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
[[Property:title|Eiffel Inspector - Running the Analyzer]]
|
||||
[[Property:link_title|Running the Analyzer]]
|
||||
[[Property:weight|-14]]
|
||||
[[Property:uuid|d672c769-57fb-6b87-2781-83daff3ab9e7]]
|
||||
= General =
|
||||
|
||||
There are several different ways of running the Eiffel Inspector. Most importantly, you can select the scope of the analysis. For example it is possible to analyze a single class, a cluster or a whole system. Also for the same scope there are different ways of running the analyzer depending on your personal preferences. To perform the analysis the Eiffel system which will be analyzed must compile without any error.
|
||||
|
||||
There are two ways of running the Eiffel Inspector
|
||||
# Using the GUI, the Eiffel Inspector Tool appears as a panel. The panel is mainly used for displaying analysis results. The command to perform the analysis can be found not only in the panel but also in various context menus making it easy to analyze specific classes or sets of classes.
|
||||
# Using command-line arguments with the command-line version of EiffelStudio. The system is compiled (if necessary) and then analyzed. The output of the analysis will be directed to the terminal window.
|
||||
|
||||
= GUI =
|
||||
== Analyzing the System ==
|
||||
|
||||
If you want to analyze the whole system of the currently open project press the '''Analyze System''' button in the toolbar. Every compiled classes of the system will be analyzed.
|
||||
[img_assist|nid=2647|title=Analyze System|desc=|link=node|align=center|width=368|height=84]
|
||||
|
||||
|
||||
== Analyzing a Class or Group ==
|
||||
|
||||
=== Current Class ===
|
||||
Left-clicking the '''Analyze Item''' button in the toolbar will start an analysis of the class that is currently opened in the editor.
|
||||
[img_assist|nid=2647|title=Analyze Item|desc=|link=node|align=center|width=368|height=84]
|
||||
|
||||
=== Any Class ===
|
||||
There are two ways of analyzing an arbitrary class (either from your system or from a library):
|
||||
* Right-click on a class name and select '''Run Eiffel Inspector on Class...''' from the context menu:
|
||||
[img_assist|nid=2648|title=Class Context Menu|desc=|link=node|align=center|width=371|height=487]
|
||||
* Pick a class and drop it on the '''Analyze Item''' button.
|
||||
|
||||
=== Clusters ===
|
||||
To analyze a cluster there are two possibilities, like for classes:
|
||||
* You can either right-click the cluster and select '''Run Eiffel Inspector on cluster''' from the context menu:
|
||||
[img_assist|nid=2649|title=Cluster Context Menu|desc=|link=node|align=center|width=247|height=220]
|
||||
* Pick a cluster and drop it on the '''Analyze Item''' button.
|
||||
|
||||
=== Others ===
|
||||
Not only clusters but any other elements of a project (such as a library) can be analyzed by pick-and-dropping it on the '''Analyze Item''' button in the panel.
|
||||
|
||||
|
||||
=Command Line=
|
||||
The Eiffel Inspector is also available from the EiffelStudio command line compiler by using the '''-code-analysis''' command. The results will be displayed in the terminal window or to a file.
|
||||
|
||||
== Execution / Command Line Options ==
|
||||
|
||||
The following command will perform a code analysis:
|
||||
|
||||
ec.exe -config project.ecf -code-analysis [-cadefaults] [-caloadprefs ''preffile''] [-caclass ''CLASS1 CLASS2 ...'']
|
||||
|
||||
The arguments in brackets are optional. For a complete description of the Eiffel inspector command line options see [[EiffelStudio: Using command line options|Using command line compiler options]].
|
||||
|
||||
EiffelStudio will try to compile the system if needed. The analysis will only work with syntactically correct code and a compiled system. Should the compilation fail, EiffelStudio will abort and the analysis will not start.
|
||||
|
||||
== Output ==
|
||||
Upon a successful compilation either the whole system or the classes mentioned in the arguments will be analyzed. The class that is currently being analyzed will be displayed so that the user can follow the progress.
|
||||
|
||||
As soon as everything needed has been analyzed the results will be displayed as a list of rule violations. These rule violations are sorted by class and by location. In addition to the name of the violated rule and the rule ID, a description of the concrete violation will be displayed as well.
|
||||
|
||||
[img_assist|nid=2650|title=Eiffel Inspector - Command Line|desc=|link=node|align=center|width=640|height=627]
|
||||
|
||||
=== Output to file ===
|
||||
|
||||
Appending "> ''filename''" to the command above will redirect the output to a text file.
|
||||
In addition, a file '''last_analysis_result.csv''' will be saved in the current working directory with the same content as '''filename''' that can be processed by a spreadsheet tool.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[[Property:title|Eiffel Inspector]]
|
||||
[[Property:weight|-9]]
|
||||
[[Property:uuid|3d9edb08-a7dd-7df9-2b1e-b5c30add6529]]
|
||||
The Inspector Eiffel is a static analyzer that will help maintain a high code quality. It is capable of detecting many different kinds of issues in the source code. These issues relate to possibly dangerous run-time behavior, performance problems, coding style, and more.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user