Articles → .NET → Cyclomatic Complexity Using Visual Studio
Cyclomatic Complexity Using Visual Studio
What Is Cyclomatic Complexity?
int x = Convert.ToInt32(Console.ReadLine());
if (x % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Odd");
Click to Enlarge
Significance Of Cyclomatic Complexity
Cyclomatic Complexity | Risk Evaluation |
---|
1 to 10 | A simple program, without much risk |
11 to 20 | More complex, moderate risk |
21 to 50 | Complex, high-risk program |
Greater than 50 | Untestable program (very high risk) |
How To Calculate Cyclomatic Complexity Using Visual Studio
- Open the project in visual studio.
- Right-click on the project and click on ‘Calculate Code Metrics’
Click to Enlarge
Click to Enlarge