9.2. Metrics Analysis

The command “Compute Metrics” allows you to analyze Ada source files using several different metric quantifiers. The command is provided in the Ada & Analyze menus on the menubar and in the contextual menus of the editor and the GNAT Project Explorer.

Note that in addition to analyzing individual files, you can analyze all the files in an entire project by selecting the project node in the GNAT Project Explorer. This option is illustrated below:

invoking metrics on a project

9.2.1. Controls

The actual analysis is provided by the external tool “gnatmetric”. See the GNAT User’s Guide for the details of using the tool. The specific switches applied are controlled via the “Metrics” package in the project’s GNAT project file (the “gpr file”).

Note that re-issuing the command only performs the analysis again if necessary; specifically, if the GNAT project file has changed or if there are no prior results in the first place.

9.2.2. Results

Analysis results are displayed in the Metrics view, with an overall summary in the Console view.

metrics summary in console

The Metrics view shows the results in a tree format, with an overall project summary provided first. Results for each file then follow the project summary. In the figure below, the view has been maximized to show more of the results, and both the summary and the results for one of the subprograms have been expanded.

metrics view showing results

The Metrics view will be opened automatically after the analysis completes. You can open the view manually, using the shortcut:

showing metrics view via shortcut