Metric-McCabeComplexity

McCabe Cyclomatic Complexity

Required inputs: RFG

Computes the number of nodes in the control flow graph of a routine that have more than one outgoing edge.

For nodes originating in switch-statements, each nonempty case section is counted. It is also known as cyclomatic complexity.

Roughly speaking, the value Metric.McCabe_Complexity is computed by summing up

  • the number of if-statements,
  • the number of loop statements (e.g. for and while),
  • the number of conditional (?) operators,
  • the number of catch clauses, and
  • the number of nonempty case-sections
  • plus the value one.

So Metric.McCabe_Complexity is always greater zero.

Possible Messages

This rule has no predefined messages.

Options

display_name

display_name : str | None = 'McCabe Cyclomatic Complexity'

Description of the metric shown in the dashboard. If None, rfg_metric_name is used.
 

max_value

max_value : int | None = 20

Maximum allowed value. None if unlimited.
 

min_value

min_value : int | None = 1

Minimum allowed value. None if unlimited.
 

rfg_metric_name

rfg_metric_name : str = 'Metric.McCabe_Complexity'

Name of the node attribute storing the metric value in the RFG.