Next: , Previous: Line Metrics Control, Up: Specifying a set of metrics to compute


15.1.3.2 Syntax Metrics Control

gnatmetric computes various syntactic metrics for the outermost unit and for each eligible local unit:

LSLOC (“Logical Source Lines Of Code”)
The total number of declarations and the total number of statements. Note that the definition of declarations is the one given in the reference manual:

“Each of the following is defined to be a declaration: any basic_declaration; an enumeration_literal_specification; a discriminant_specification; a component_declaration; a loop_parameter_specification; a parameter_specification; a subprogram_body; an entry_declaration; an entry_index_specification; a choice_parameter_specification; a generic_formal_parameter_declaration.”

This means for example that each enumeration literal adds one to the count, as well as each subprogram parameter.

Thus the results from this metric will be significantly greater than might be expected from a naive view of counting semicolons.

Maximal static nesting level of inner program units
According to Ada Reference Manual, 10.1(1), “A program unit is either a package, a task unit, a protected unit, a protected entry, a generic unit, or an explicitly declared subprogram other than an enumeration literal.”
Maximal nesting level of composite syntactic constructs
This corresponds to the notion of the maximum nesting level in the GNAT built-in style checks (see Style Checking)

For the outermost unit in the file, gnatmetric additionally computes the following metrics:

Public subprograms
This metric is computed for package specs. It is the number of subprograms and generic subprograms declared in the visible part (including the visible part of nested packages, protected objects, and protected types).
All subprograms
This metric is computed for bodies and subunits. The metric is equal to a total number of subprogram bodies in the compilation unit. Neither generic instantiations nor renamings-as-a-body nor body stubs are counted. Any subprogram body is counted, independently of its nesting level and enclosing constructs. Generic bodies and bodies of protected subprograms are counted in the same way as “usual” subprogram bodies.
Public types
This metric is computed for package specs and generic package declarations. It is the total number of types that can be referenced from outside this compilation unit, plus the number of types from all the visible parts of all the visible generic packages. Generic formal types are not counted. Only types, not subtypes, are included.

Along with the total number of public types, the following types are counted and reported separately:


All types
This metric is computed for any compilation unit. It is equal to the total number of the declarations of different types given in the compilation unit. The private and the corresponding full type declaration are counted as one type declaration. Incomplete type declarations and generic formal types are not counted. No distinction is made among different kinds of types (abstract, private etc.); the total number of types is computed and reported.

By default, all the syntax metrics are computed and reported. You can use the following switches to select specific syntax metrics.

--syntax-all
Report all the syntax metrics
--no-syntax-all
Do not report any of syntax metrics
--declarations
Report the total number of declarations
--no-declarations
Do not report the total number of declarations
--statements
Report the total number of statements
--no-statements
Do not report the total number of statements
--public-subprograms
Report the number of public subprograms in a compilation unit
--no-public-subprograms
Do not report the number of public subprograms in a compilation unit
--all-subprograms
Report the number of all the subprograms in a compilation unit
--no-all-subprograms
Do not report the number of all the subprograms in a compilation unit
--public-types
Report the number of public types in a compilation unit
--no-public-types
Do not report the number of public types in a compilation unit
--all-types
Report the number of all the types in a compilation unit
--no-all-types
Do not report the number of all the types in a compilation unit
--unit-nesting
Report the maximal program unit nesting level
--no-unit-nesting
Do not report the maximal program unit nesting level
--construct-nesting
Report the maximal construct nesting level
--no-construct-nesting
Do not report the maximal construct nesting level