Complexity Metrics

Definitions of Cyclomatic Complexity, Integration Complexity, and Essential Complexity.

CAST Imaging shows three complexity metrics for every object. Understanding them helps you identify high-risk code.

Cyclomatic Complexity (CC)

Cyclomatic Complexity measures the number of independent paths through a piece of code.

  • A method with no branches has CC = 1.
  • Each if, for, while, case, or similar branch adds 1 to the CC.
  • A higher CC means more paths to test and a higher chance of bugs.

Guideline: CC > 10 is considered complex. CC > 25 is very complex and should be reviewed.

Integration Complexity (IC)

Integration Complexity measures how many other objects this object depends on.

  • A higher IC means the object is tightly coupled to many other parts of the system.
  • Tightly coupled objects are harder to change, test, and migrate.

Essential Complexity (EC)

Essential Complexity measures how much of the code structure cannot be simplified into a clear linear flow.

  • High EC indicates unstructured code (heavy use of goto, deeply nested conditions, or non-standard control flow).
  • High EC often correlates with difficulty in maintaining or understanding the code.

Where to see metrics