14.1.4 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
- Maximal static nesting level of inner program units
- According to
Ada 95 Language 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 specifications. It is the
number of subprograms and generic subprograms declared in the visible
part (including in 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 specifications 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:
- Abstract types
- Root tagged types (abstract, non-abstract, private, non-private). Type
extensions are not counted
- Private types (including private extensions)
- Task types
- Protected types
- 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;
if any of these is set, only the explicitly specified metrics are computed.
- -ed
- The total number of declarations
- -es
- The total number of statements
- -eps
- The number of public subprograms in a compilation unit
- -eas
- The number of all the subprograms in a compilation unit
- -ept
- The number of public types in a compilation unit
- -eat
- The number of all the types in a compilation unit
- -enu
- The maximal program unit nesting level
- -ec
- The maximal construct nesting level