nmbl Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

ac - Aggregate Complexity

Overview

The ac command calculates aggregate complexity for C# projects or solutions. Aggregate Complexity (AC) is a project-level metric that sums the cyclomatic complexity contributions from all methods, providing a single number that represents the overall complexity of your codebase.

How It Works

Only methods whose individual cyclomatic complexity score is 10 or greater contribute to the Aggregate Complexity total. Methods below that threshold are ignored entirely. This focuses attention on methods that exceed healthy complexity thresholds and keeps the metric stable for well-maintained codebases where most methods are simple.

Syntax

nmbl ac <Path> [options]

Arguments

  • Path - Path to a .csproj file, .slnx solution file, or directory containing C# files

Options

  • --verbose, -v - Show breakdown of methods contributing to AC

Output

By default, outputs just the integer aggregate complexity value. With --verbose, displays a table of contributing methods.

Examples

Analyze a Specific Project

nmbl ac src/MyProject/MyProject.csproj

Outputs just the aggregate complexity number:

12

Analyze a Solution

nmbl ac MySolution.slnx

Calculates AC across all projects in the solution.

Verbose Output

nmbl ac src/MyProject/ --verbose

Shows contributing methods:

Analyzing 45 C# file(s)...

Methods contributing to Aggregate Complexity:

╭───────────────────────────────────────────────────────╮──────────────╮─────────────────╮
│ Method                                                │ Complexity   │ AC Contribution │
├───────────────────────────────────────────────────────┼──────────────┼─────────────────┤
│ MyNamespace.OrderProcessor.ProcessOrder(Order)        │           25 │               2 │
│ MyNamespace.ReportGenerator.GenerateReport(int, bool) │           18 │               1 │
│ MyNamespace.DataValidator.ValidateAll(object[])       │           12 │               1 │
╰───────────────────────────────────────────────────────╯──────────────╯─────────────────╯

Total methods analyzed: 128
Methods contributing to AC: 3 (CC >= 10)

Aggregate Complexity: 4

Use in CI/CD

The simple integer output makes ac ideal for CI/CD pipelines:

# Check if aggregate complexity exceeds threshold
$ac = nmbl ac src/MyProject/
if ($ac -gt 50) {
    Write-Error "Aggregate complexity too high: $ac"
    exit 1
}

Understanding Aggregate Complexity

Aggregate Complexity helps you:

  • Track technical debt - Monitor overall complexity trends over time
  • Compare projects - Objectively compare complexity between projects
  • Set thresholds - Establish complexity budgets for teams or projects
  • Identify hotspots - Use --verbose to find the most complex methods

Typical AC Values:

  • 0-10: Small, well-maintained codebase
  • 10-50: Medium project with some complex areas
  • 50-100: Large project or significant complexity
  • 100+: Large project requiring attention to complexity
  • cc - Calculate cyclomatic complexity for individual methods
  • cogc - Calculate cognitive complexity
  • loc - Count lines of code