Cyclomatic Complexity
A code complexity metric introduced by Thomas McCabe in 1976. It measures the number of independent execution paths through a program, and it is generally recommended that a single function not exceed a cyclomatic complexity of 10.
Core Facts
Cyclomatic Complexity was proposed by Thomas McCabe in 1976 to measure the complexity of a program's control flow.
Cyclomatic complexity was proposed by Thomas McCabe in 1976, calculated as M = E - N + 2P, and the industry typically sets the upper limit of cyclomatic complexity for a single module at 10–15.
The industry generally considers that a cyclomatic complexity exceeding 10 for a single function requires refactoring
Timeline (last 90 days)
Passing tests cannot detect degradation in code structure, such as surging cyclomatic complexity, bloated functions, or key logic being skipped by tests.
A common rule-of-thumb threshold is that a single function's cyclomatic complexity should not exceed 10; exceeding it is treated as a refactoring signal.
Cyclomatic complexity only counts control flow branches and is completely insensitive to data coupling, naming quality, and whether the level of abstraction is appropriate.
Cyclomatic Complexity, proposed by Thomas McCabe in 1976, quantifies code complexity by counting the number of independent execution paths in the code.
Software engineering generally recommends that the cyclomatic complexity of a single function not exceed 10.
Commonly used metrics for code quality assessment include cyclomatic complexity, code duplication rate, unit test coverage, and whether SOLID principles are followed.
All Facts (12)
Cyclomatic Complexity was proposed by Thomas McCabe in 1976 to measure the complexity of a program's control flow.
80%VerifiedCyclomatic complexity was proposed by Thomas McCabe in 1976, calculated as M = E - N + 2P, and the industry typically sets the upper limit of cyclomatic complexity for a single module at 10–15.
65%VerifiedThe industry generally considers that a cyclomatic complexity exceeding 10 for a single function requires refactoring
65%UnverifiedCommonly used metrics for code quality assessment include cyclomatic complexity, code duplication rate, unit test coverage, and whether SOLID principles are followed.
60%UnverifiedWhen AI models generate code, they lack persistent memory of the overall architecture and tend toward local patching rather than global refactoring in each iteration, causing cyclomatic complexity and coupling to continuously rise.
60%UnverifiedIt is generally considered that functions with a cyclomatic complexity exceeding 10 require close attention, and those exceeding 20 are classified as high-risk code
60%UnverifiedIn the industry, a cyclomatic complexity of 10 is generally considered a warning threshold, and exceeding 20 is considered to make code difficult to maintain and test.
60%UnverifiedA common rule-of-thumb threshold is that a single function's cyclomatic complexity should not exceed 10; exceeding it is treated as a refactoring signal.
50%UnverifiedPassing tests cannot detect degradation in code structure, such as surging cyclomatic complexity, bloated functions, or key logic being skipped by tests.
50%UnverifiedCyclomatic complexity only counts control flow branches and is completely insensitive to data coupling, naming quality, and whether the level of abstraction is appropriate.
50%UnverifiedCyclomatic Complexity, proposed by Thomas McCabe in 1976, quantifies code complexity by counting the number of independent execution paths in the code.
50%UnverifiedSoftware engineering generally recommends that the cyclomatic complexity of a single function not exceed 10.
50%