Cyclomatic complexity is a software metric used to indicate the complexity of a program. It represents the number of linearly independent paths through a program's source code [wiki].
It also represents the minimum ideal number of tests, each testing a path.
There are two ways to calculate it :
- Using the control flow graph of the program : Complexity = E - N + 2 (where E = number of edges and N = number of nodes)
- Or by calculating the number of decision points ("if" statements or conditional loops) contained in that program plus one : Complexity = P + 1 (where P = number of decision points)
Launch complexity analysis
BluInsights offers cyclomatic complexity analysis for multiple languages (see the complete list).
The proposed complexity analysis is performed using the Blu Age products leveraging advanced parsing features for multiple languages (mainly legacy). Launching the analysis is as simple as selecting the programming language.
The analysis of large projects (thousands of programs) may take few minutes. You will receive an email when the results are available. In the meantime, you can use the other features.
Cyclomatic Complexity Computation
The cyclomatic complexity of any structured program with only one entry point and one exit point is equal to the number of decision points contained in that program plus one. The decision points are if, for, for-each, while, do, catch and case statements. For each method in a program, we calculate this cyclomatic complexity, and the sum of the cyclomatic complexity of each method of a file gives the total cyclomatic complexity of the file.
Each language has only certain types of files containing code: if a file doesn't contains code (such as Images), all the values are 0.
|Language||Files Extension with Code|
|PowerBuilder||SRM, SRU, SRW|
|Natural||NSP, NSM, NSN, NSC, NSH|
The Total Cyclomatic Complexity corresponds to the sum of the Cyclomatic Complexity of all the files in the project.
The Cyclomatic Complexity result is displayed as a table with all the files within the project. Each file is associated with its total cyclomatic complexity, method count and average cyclomatic complexity per method.
Some files might not have been parsed correctly, these are shown with a warning sign in place of their cyclomatic complexity values.
The result can also be displayed as a graph, with the number of Lines of Code as the x-axis and the Total Cyclomatic Complexity as the y-axis, each dot corresponding to a file.
The analysis can be launched as many as you want. The intermediate results will not be saved.