scitools.com

McCabe

Thomas McCabe introduced Cyclomatic Complexity, along with Essential Complexity, in his 1976 paper "A Complexity Measure" [1]. Cyclomatic Complexity counts the decision points in a function plus one; Essential Complexity does the same after iteratively replacing well-structured control structures (like if/else and loops) with a single statement, isolating the "unstructured" part of the complexity. See Interpreting Cyclomatic Complexity ↗ for risk-threshold guidance (such as the SEI's commonly cited bands) on reading the values these metrics produce.

McCabe Metrics

Name Acronym Understand Metric ID
Cyclomatic Complexity CC Cyclomatic
Strict Cyclomatic Complexity CC2 CyclomaticStrict
Modified Cyclomatic Complexity CC3 CyclomaticModified
Essential Complexity ev(G) Essential

Notes:

  1. Strict Modified Cyclomatic Complexity and Strict Modified Essential Complexity combine both the Strict and Modified adjustments. Understand computes them for convenience, but they aren't named/numbered variants in McCabe's own work, so they're left out of the table above and not tagged as part of this suite.
  2. Knot Count (Knots, and its Max/Min essential-complexity variants) measures a related kind of control-flow complexity, but it comes from Woodward, Hennell, and Hedley [2], not McCabe, so it also isn't part of this suite.

Aggregated Values

Each metric above is also available summed, maxed, and averaged across a class, file, architecture, or the whole project:

Metric Sum Max Average
Cyclomatic Complexity SumCyclomatic MaxCyclomatic AvgCyclomatic
Strict Cyclomatic Complexity SumCyclomaticStrict MaxCyclomaticStrict AvgCyclomaticStrict
Modified Cyclomatic Complexity SumCyclomaticModified MaxCyclomaticModified AvgCyclomaticModified
Essential Complexity SumEssential MaxEssential AvgEssential

References

  1. McCabe, Thomas J. "A Complexity Measure." IEEE Transactions on Software Engineering, vol. SE-2, no. 4, 1976, pp. 308-320.
  2. Woodward, M.R., M.A. Hennell, and D. Hedley. "A Measure of Control Flow Complexity in Program Text." IEEE Transactions on Software Engineering, vol. SE-5, no. 1, 1979, pp. 45-50.

McCabe Plugins

Name Kind
Average Cyclomatic Complexity Metric
Average Essential Complexity Metric
Average Modified Cyclomatic Complexity Metric
Average Strict Cyclomatic Complexity Metric
Cyclomatic Complexity Metric
Essential Complexity Metric
Max Cyclomatic Complexity Metric
Max Essential Complexity Metric
Max Modified Cyclomatic Complexity Metric
Max Strict Cyclomatic Complexity Metric
Modified Cyclomatic Complexity Metric
Strict Cyclomatic Complexity Metric
Sum Cyclomatic Complexity Metric
Sum Essential Complexity Metric
Sum Modified Cyclomatic Complexity Metric
Sum Strict Cyclomatic Complexity Metric