Running the Code Analyzer

General

There are several different ways of running the Code Analyzer. 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 Code Analyzer

  1. Using the GUI, the Code Analyzer 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.
  2. 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.

Analyze System

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.

Analyze Item

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 Analyze Class... from the context menu:

Class Context Menu

  • 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 Analyze cluster from the context menu:

Cluster Context Menu

  • 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 Code Analyzer 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 ...'']
[-caforcerules "RULE1 (First preference=1, Second preference=2) RULE2"]

The arguments in brackets are optional. For a complete description of the Code Analyzer command line options see 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.

Code Analyzer - Command Line

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 'EIFGENs/target' directory, with the same content as filename, that can be processed by a spreadsheet tool.

cached: 12/09/2024 7:14:27.000 AM