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");




Picture showing the execution workflow of the code
Click to Enlarge




Significance Of Cyclomatic Complexity




Cyclomatic ComplexityRisk Evaluation
1 to 10A simple program, without much risk
11 to 20More complex, moderate risk
21 to 50Complex, high-risk program
Greater than 50Untestable program (very high risk)



How To Calculate Cyclomatic Complexity Using Visual Studio




  1. Open the project in visual studio.
  2. Right-click on the project and click on ‘Calculate Code Metrics’
Picture showing the option of calculating the cyclomatic complexity in visual studio
Click to Enlarge



Picture showing the result of cyclomatic complexity in visual studio
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, February 7, 2016

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250