See the definition of Ndepend Cyclomatic Complexity .
Nesting depth is also an excellent code metric.
Cyclomatic complexity is a popular procedural software metric equal to the number of decisions that can be made in a procedure. Specifically, in C # CC, a method has a value of 1 + {the number of the following expressions found in the method body}:
if | a | for | foreach | case | default | continue | Go to | && | || | catch | ternary operator ?: | ??
The following expressions are not taken into account when calculating CC:
else | to do | switch | try | use | quit | finally | back | creation of objects | method call | access to fields
Adapted to the world of OO, this metric is determined both by methods and classes / structures (as the sum of its SS methods). Note that the CC of an anonymous method is not taken into account when calculating the CC of its external method.
Recommendations Methods where CC is above 15 are difficult to understand and maintain. Methods in which CC is above 30 are extremely complex and must be separated by smaller methods (unless they are automatically generated by the tool).
source share