Software → Software Design
Cognitive Complexity
A metric intended to approximate how difficult control flow is for a human reader to understand.
Cognitive Complexity
Cognitive Complexity estimates the mental effort required to follow code. It typically penalizes nested control flow, interruptions such as breaks or continues, and structures that force readers to maintain multiple layers of context.
Unlike Cyclomatic Complexity, it is designed around readability rather than the mathematical count of execution paths. Two functions can have similar path counts while one is substantially harder to understand because of nesting and indirect flow.
Use it as a review signal alongside naming, cohesion, coupling, and domain clarity.