Cyclomatic complexity measures a program or method by counting its branching points. It also represents the number of independent paths from entry to exit. section 7.1
1 + <number of branching points>
Calculate the metric as 1 plus the number of branching points. A method without control-flow statements therefore has complexity 1. section 7.1
Use the metric to reason about testing and refactoring:
- Treat each simplest predicate as a branching point; an AND condition contributes two, producing complexity 3. section 7.1
- Use independent paths as an indication of the tests needed for complete branch coverage. section 7.1
- Prioritize complex, domain-significant code for unit testing because it offers stronger regression protection. section 7.1




