liveBook · Manning

Cyclomatic complexity

Cyclomatic complexity is a software metric that measures the number of linearly independent execution paths through a program's control-flow graph.

How 5 Manning books explain it

Practices of the Python Pro

Cyclomatic complexity is a software metric that measures the number of linearly independent paths through a program's control-flow graph.

How it is used
Guides maintainability work by revealing functions whose branching and looping deserve refactoring attention.
How deep it goes
Defines execution paths, sketches control-flow graph counting, and demonstrates refactoring, while deferring formal mathematical analysis.
Examples
Uses Python functions for long-word detection, GitHub-star importing, and response formatting with JSON, XML, and configuration mappings.
What you can do after
Diagnose/debug with it by spotting path-heavy functions, measuring them manually or with Radon and SonarQube, and reducing branching through refactoring.

Read how Practices of the Python Pro explains cyclomatic complexity →

Unit Testing Principles, Practices, and Patterns

Cyclomatic complexity is a metric that counts the independent control-flow paths or branching structure in a program or method.

How it is used
Uses branching structure to classify code and guide unit-testing and refactoring priorities.
How deep it goes
Defines the formula, independent-path interpretation, and compound-predicate counting, but does not develop a broader measurement system.
Examples
Uses a branch-free method and an AND condition to demonstrate complexity calculations.
What you can do after
Evaluate branching complexity and estimate the tests associated with complete branch coverage.

Read how Unit Testing Principles, Practices, and Patterns explains cyclomatic complexity →

Functional Programming in JavaScript

A software metric that counts the number of linearly independent paths through a program’s control flow.

How it is used
Measures control-flow complexity when comparing imperative and functional implementations.
How deep it goes
Defines independent execution paths and compares measured values, without deriving the metric calculation.
Examples
Uses the imperative and functional showStudent implementations and their metric comparison.
What you can do after
Evaluate implementations by comparing their control-flow complexity and related static metrics.

Read how Functional Programming in JavaScript explains cyclomatic complexity →

The Art of Code

Cyclomatic complexity is a software metric that counts the independent execution paths through a program's control flow based on its decision points.

How it is used
Quantifies control-flow complexity for code review, static analysis, and maintainability investigation.
How deep it goes
Defines independent execution paths and decision-point counting, but stops short of capturing readability, nesting, or Boolean entanglement fully.
Examples
Uses if, while, and switch statements as decision-point examples and contrasts equal scores with different readability costs.
What you can do after
Evaluate methods with a structural metric and investigate whether refactoring or complexity containment is appropriate.

Read how The Art of Code explains cyclomatic complexity →

AI-Powered Developer: Build software with ChatGPT and Copilot

Cyclomatic complexity is a metric that counts the independent execution paths through a software module based on its decision points.

How it is used
Uses decision-path complexity to assess code quality, maintainability, and likely testing effort.
How deep it goes
Defines independent paths and connects higher values to maintenance and testing difficulty, but does not derive a calculation formula.
Examples
Uses Copilot questions about the Department-StatisticsVisitor class and an observed complexity value of 1.
What you can do after
Evaluate code structure with a complexity reading and identify when additional testing or simplification may be warranted.

Read how AI-Powered Developer: Build software with ChatGPT and Copilot explains cyclomatic complexity →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.