cc - Cyclomatic Complexity
The cc command calculates cyclomatic complexity for C# methods in your projects or directories. Cyclomatic complexity counts the number of linearly independent paths through a method. A score of 1 means a single path with no branches; higher scores indicate more conditional logic and typically correlate with harder-to-test code.
nmbl cc <ProjectFileOrDirectory>
ProjectFileOrDirectory- Path to a.csprojfile, a project directory, or.for the current directory.
Prints the count of files being analyzed, then displays a rounded table of the top 10 methods ranked by cyclomatic complexity (highest first), followed by the total number of methods analyzed.
Analyzing 42 C# file(s)...
Top 10 methods by cyclomatic complexity:
╭──────────────────────────────────────────────────────────────╮────────────╮
│ Method │ Complexity │
├──────────────────────────────────────────────────────────────┼────────────┤
│ MyNamespace.OrderProcessor.ProcessOrder(Order) │ 25 │
│ MyNamespace.ReportGenerator.GenerateReport(int, bool) │ 18 │
╰──────────────────────────────────────────────────────────────╯────────────╯
Total methods analyzed: 128
0- Success, including when no C# files or methods are found.1- The required path argument is missing or an unexpected error occurs.
nmbl cc src/MyProject/MyProject.csproj
Calculates complexity for all methods in the specified project.
nmbl cc src/
Recursively analyzes all C# files in the directory tree.
nmbl cc .
Analyzes all C# files in the current directory and subdirectories.
Methods with higher cyclomatic complexity scores are generally:
- Harder to understand and reason about
- More difficult to write thorough tests for
- More prone to defects
- Good candidates for refactoring
Complexity guidelines:
- 1–10: Simple, easy to understand
- 11–20: Moderate complexity, consider refactoring
- 21–50: High complexity, should be refactored
- 50+: Very high complexity, critical to refactor
Industry guidelines commonly flag methods above 10 as candidates for refactoring.