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


14.1.3.3 Complexity Metrics Control

For a program unit that is an executable body (a subprogram body (including generic bodies), task body, entry body or a package body containing its own statement sequence) gnatmetric computes the following complexity metrics:

The McCabe complexity metrics are defined in http://www.mccabe.com/pdf/nist235r.pdf

According to McCabe, both control statements and short-circuit control forms should be taken into account when computing cyclomatic complexity. For each body, we compute three metric values:

When computing cyclomatic and essential complexity, gnatmetric skips the code in the exception handlers and in all the nested program units.

By default, all the complexity metrics are computed and reported. For more fine-grained control you can use the following switches:

--complexity-all
Report all the complexity metrics
--no-complexity-all
Do not report any of complexity metrics
--complexity-cyclomatic
Report the McCabe Cyclomatic Complexity
--no-complexity-cyclomatic
Do not report the McCabe Cyclomatic Complexity
--complexity-essential
Report the Essential Complexity
--no-complexity-essential
Do not report the Essential Complexity
--loop-nesting
Report maximal loop nesting level
--no-loop-nesting
Do not report maximal loop nesting level
--complexity-average
Report the average McCabe Cyclomatic Complexity for all the subprogram bodies, task bodies, entry bodies and statement sequences in package bodies. The metric is computed and reported for whole set of processed Ada sources only.
--no-complexity-average
Do not report the average McCabe Cyclomatic Complexity for all the subprogram bodies, task bodies, entry bodies and statement sequences in package bodies


-ne
Do not consider exit statements as gotos when computing Essential Complexity