Cyclomatic Complexity Calculator

Your details

Graph-based uses the control-flow graph edge and node counts. Decision-based simply counts if/else/for/while/case/catch/&&/|| operators and adds one.
Number of directed edges in the control-flow graph of the function or module.
Number of nodes (basic blocks) in the control-flow graph.
Number of connected components. Almost always 1 for a single function; use a higher value only for a program with multiple disconnected routines.
Cyclomatic complexity (M)Low risk
3

McCabe cyclomatic complexity index

Risk levelLow risk
Minimum test cases3
Decision points used2
3 M
Low<4Moderate4-7High7-10Very high10+

Complexity 3: Low risk.

  • A cyclomatic complexity of 3 means there are 3 linearly independent paths through this code.
  • You need at least 3 test cases to achieve full branch coverage.
  • Simple, easy to test and maintain.

Next stepThis module is straightforward. Keep it that way by reviewing any future decision points before adding them.

= Powered by OnlyCalculators