Next: , Previous: Local_Packages, Up: Predefined Rules

23.6.26 Metrics

There is a set of checks based on computing a metric value and comparing the result with the specified upper (or lower, depending on a specific metric) value specified for a given metric. A construct is flagged if a given metric is applicable (can be computed) for it and the computed value is greater then (lover then) the specified upper (lower) bound.

The name of any metric-based rule consists of the prefix Metrics_ followed by the name of the corresponding metric (see the table below). For +R option, each metric-based rule has a numeric parameter specifying the bound (integer or real, depending on a metric), -R option for metric rules does not have a parameter.

The following table shows the metric names for that the corresponding metrics-based checks are supported by gnatcheck, including the constraint that must be satisfied by the bound that is specified for the check and what bound - upper (U) or lower (L) - should be specified.

Check Name Description Bounds Value
Essential_Complexity Essential complexity Positive integer (U)
Cyclomatic_Complexity Cyclomatic complexity Positive integer (U)
LSLOC Logical Source Lines of Code Positive integer (U)

The meaning and the computed values for all these metrics are exactly the same as for the corresponding metrics in gnatmetric.

Example: the rule

     +RMetrics_Cyclomatic_Complexity : 7

means that all bodies with cyclomatic complexity exceeding 7 will be flagged.

To turn OFF the check for cyclomatic complexity metric, use the following option: