Cyclomatic Complexity is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Cyclomatic Complexity
API ID: CyclomaticAlso Known As: Cyclomatic Complexity (CC)
Languages: Ada, Assembly, Basic, C#, C++, Fortran, Java, Jovial, Pascal, Python, Rust, VHDL, Web
Targets: Files, Functions, Modules, Packages, Subprograms
McCabe Cyclomatic Complexity, the number of decision points + 1.
McCabe Cyclomatic complexity as per the original NIST paper on the subject. The cyclomatic complexity of any structured program with only one entrance point and one exit point is equal to the number of decision points contained in that program plus one. Understand counts the keywords for decision points (FOR, WHILE, etc) and then adds 1. For a switch statement, each 'case' is counted as 1. For languages with macros, the expanded macro text is also included in the calculation.
Also known as McCabe - Cyclomatic Complexity (CC).
- Ada: Type, Entry, Function, Package, Procedure, Protected, Task
- Basic: Method
- C#: Method
- C++: Function
- Fortran: Module, Block Data, Function, Program, Subroutine
- Java: Method
- Jovial: Subroutine
- Pascal: Compunit, Function, Procedure
- Python: File, Function
- Rust: Function
- VHDL: Procedure, Function, Process
- Web: File
- The cyclomatic metric used is configured from "Project Configuration/Metrics/Complexity". This metric results from having "Count each decision in a multi-way-decision structure" on and having "Count logical conjuctions (OR) and logical and (AND)" off. Checking "Show all available cyclomatic complexity metric variants" will also enable the metric.