Next: SPARK Ada Rules, Previous: Feature Usage Rules [Contents][Index]
The rules in this chapter can be used to enforce compliance with specific code metrics, by checking that the metrics computed for a program lie within user-specifiable bounds. Depending on the metric, there may be a lower bound, an upper bound, or both. A construct is flagged if the value of the metric exceeds the upper bound or is less than the lower bound.
• Metrics_Essential_Complexity: | ||
• Metrics_Cyclomatic_Complexity: | ||
• Metrics_LSLOC: |
The name of any metrics rule consists of the prefix Metrics_
followed by the name of the corresponding metric:
Essential_Complexity
, Cyclomatic_Complexity
, or
LSLOC
.
(The “LSLOC” acronym stands for “Logical Source Lines Of Code”.)
The meaning and the computed values of the metrics are
the same as in gnatmetric
.
For the +R option, each metrics rule has a numeric parameter specifying the bound (integer or real, depending on a metric). The -R option for the metrics rules does not have a parameter.
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:
-RMetrics_Cyclomatic_Complexity
Next: Metrics_Cyclomatic_Complexity, Up: Metrics-Related Rules [Contents][Index]
Metrics_Essential_Complexity
The Metrics_Essential_Complexity
rule takes a positive integer as
upper bound. A construct exceeding this limit will be flagged.
Next: Metrics_LSLOC, Previous: Metrics_Essential_Complexity, Up: Metrics-Related Rules [Contents][Index]
Metrics_Cyclomatic_Complexity
The Metrics_Cyclomatic_Complexity
rule takes a positive integer as
upper bound. A construct exceeding this limit will be flagged.
Previous: Metrics_Cyclomatic_Complexity, Up: Metrics-Related Rules [Contents][Index]
Metrics_LSLOC
The Metrics_LSLOC
rule takes a positive integer as
upper bound. A compilation unit exceeding this limit will be flagged.
Previous: Metrics_Cyclomatic_Complexity, Up: Metrics-Related Rules [Contents][Index]