Finding & reducing complexity¶
Complexity is the tax you pay on every future change: complex code is harder to read, test, and modify without breaking something. Understand won't decide for you what "too complex" means — it's deliberately metric-agnostic — but it makes complexity easy to find, measure, reduce, and hold down. This page walks that loop.
1. Find where complexity concentrates¶
Complexity is rarely spread evenly; it clusters. Surface the clusters:
- Where is my risky / complex code? is the main tool page — the Metrics Treemap and Heatmap make big, complex, violation-heavy units stand out at a glance.
- The Home dashboard gives ready-made "Most Complex Functions / Classes / Files" cards for a one-screen view.
2. Understand what the number means¶
A high number is only actionable if you know what it measures. Before you react to a metric:
- What does Cyclomatic Complexity mean? explains the most common complexity metric.
- Interpret key metrics (when to worry) tells you which thresholds actually matter.
- In automotive software development, the HIS metrics set defines complexity limits your program may already be contractually held to.
3. Reduce it safely¶
The classic complexity fix is extracting cohesive pieces out of an overgrown function. Do it with the model-aware refactorings so references stay correct — see Refactor safely (Rename, Inline, Extract). For a larger restructuring effort, follow Refactoring at scale.
4. Enforce a ceiling¶
Once complexity is down, stop it creeping back up. Make crossing a limit fail a check instead of relying on review vigilance — CodeCheck ships with complexity-based and structure-based rules you can turn on and run in CI, and you view & triage the violations like any other finding.
5. Track the trend¶
Prove the ceiling is holding. Export & track metrics over time lets you watch complexity project-wide across releases, and the Changes Treemap shows where it moved between two points.