NDepend.API Documentation
CyclomaticComplexity Property (IMethod)
NDepend.CodeModel Namespace > IMethod Interface : CyclomaticComplexity Property
Gets a numeric nullable value measuring this method body complexity computed from source code.
Syntax
Nullable<ushort> CyclomaticComplexity {get;}

Property Value

null if this method is declared in a third-party assembly.
null if this method is abstract or is a default constructor.
null if the PDB file of this method parent's assembly, hasen't been found.
null if the source code file path referenced from the PDB file cannot be found.
null if the source code of this method is written with a programming language different than C#.
Otherwise returns this method body complexity computed from source code.
More information on this can be found at: Understanding NDepend Analysis Inputs
If source code CC is not available for a non-abstract method, the code metric IMethod.ILCyclomaticComplexity can be used instead.
Remarks
Cyclomatic Complexity code metric description:
The Cyclomatic Complexity (CC) is a popular procedural software metric equal to the number of decisions that can be taken in a procedure.
Concretely, in C# the CC of a method is 1 + {the number of following expressions found in the body of the method}:

if | while | for | foreach | case | default | continue | goto | && | || | catch | ternary operator ?: | ??

Following expressions are not counted for CC computation:

else | do | switch | try | using | throw | finally | return | object creation | method call | field access

Notice that the CC of a lambda method or an anonymous method is not counted when computing the CC of its outer method.

Recommendations:
Methods where CC is higher than 15 are hard to understand and maintain. Methods where CC is higher than 30 are extremely complex and should be split in smaller methods (except if they are automatically generated by a tool).
Requirements

Target Platforms: Windows 11, 10, 8, 7 and Linux, MacOS with net8.0, net7.0 or net6.0 installed

See Also

Reference

IMethod Interface
IMethod Members