ComplexityRipper 1.0.1
dotnet tool install --global ComplexityRipper --version 1.0.1
dotnet new tool-manifest
dotnet tool install --local ComplexityRipper --version 1.0.1
#tool dotnet:?package=ComplexityRipper&version=1.0.1
nuke :add-package ComplexityRipper --version 1.0.1
ComplexityRipper
A Roslyn-based code complexity analyzer that scans C# repositories for long functions, high cyclomatic complexity, and deep nesting. Generates self-contained HTML reports with hyperlinks to source files in Azure DevOps and GitHub.
Installation
dotnet tool install -g ComplexityRipper
Quick Start
Scan a directory of repos and generate an HTML report with default thresholds (200 lines, 25 complexity):
complexityripper run --root C:\src\my-repos
This produces two files: stats.json (raw metrics) and code-complexity-report.html (the report).
Usage Examples
Scan a single repo
--root can point to a single git repo or a directory containing multiple repos. ComplexityRipper auto-detects which case it is by checking for a .git directory.
complexityripper run --root C:\src\MyProject
Scan multiple repos
complexityripper run --root C:\src\all-repos
Custom output paths
complexityripper run --root C:\src\my-repos --output my-report.html --stats my-stats.json
Custom thresholds
Flag functions with 300+ lines or cyclomatic complexity of 20+:
complexityripper run --root C:\src\my-repos --threshold-lines 300 --threshold-complexity 20
Include/exclude repos
complexityripper run --root C:\src\my-repos --include "ProjectA|ProjectB"
complexityripper run --root C:\src\my-repos --exclude "Tests|Legacy"
Two-step workflow: analyze once, adjust thresholds later
Generate the JSON once (the slow part), then re-generate the HTML report with different thresholds without re-scanning:
complexityripper analyze --root C:\src\my-repos --output stats.json
complexityripper report --input stats.json --threshold-lines 100 --output strict-report.html
complexityripper report --input stats.json --threshold-lines 500 --output lenient-report.html
Analyze only (JSON output)
complexityripper analyze --root C:\src\my-repos --output stats.json
Generate report from existing JSON
complexityripper report --input stats.json --output report.html --threshold-lines 200 --threshold-complexity 25
Commands
| Command | Description |
|---|---|
run |
Analyze repos and generate HTML report in one step |
analyze |
Scan repositories and output analysis JSON |
report |
Generate HTML report from analysis JSON |
Options
run
| Option | Default | Description |
|---|---|---|
--root |
(required) | Root directory: a single git repo or a directory containing multiple repos |
--output |
code-complexity-report.html |
Output HTML report file path |
--stats |
stats.json |
Intermediate stats JSON file path |
--threshold-lines |
200 |
Line count threshold for flagging functions |
--threshold-complexity |
25 |
Cyclomatic complexity threshold |
--theme |
light |
Report theme: light, dark, high-contrast, ink |
--include |
Regex to include repos (use | for OR) | |
--exclude |
Regex to exclude repos (use | for OR) | |
--include-tests |
false |
Include test projects (excluded by default) |
--repo-metadata |
Path to repo-metadata.json for lifecycle tags |
analyze
| Option | Default | Description |
|---|---|---|
--root |
(required) | Root directory to scan |
--output |
stats.json |
Output JSON file path |
--include |
Regex to include repos (use | for OR) | |
--exclude |
Regex to exclude repos (use | for OR) | |
--include-tests |
false |
Include test projects (excluded by default) |
report
| Option | Default | Description |
|---|---|---|
--input |
stats.json |
Input JSON file path (from a previous analyze or run) |
--output |
code-complexity-report.html |
Output HTML file path |
--threshold-lines |
200 |
Line count threshold for flagging functions |
--threshold-complexity |
25 |
Cyclomatic complexity threshold |
--theme |
light |
Report theme: light, dark, high-contrast, ink |
--repo-metadata |
Path to repo-metadata.json for lifecycle tags |
How It Works
C# Analysis (Roslyn)
For C# files, ComplexityRipper uses the Roslyn compiler APIs (Microsoft.CodeAnalysis.CSharp) for accurate syntax tree parsing. It finds all methods, constructors, property accessors, and local functions, then computes:
Line count -- total lines of the function body. Cyclomatic complexity -- decision points (see table below). Parameter count -- number of parameters. Max nesting depth -- deepest nesting of control flow blocks.
Hyperlinks
The HTML report generates clickable hyperlinks for every repo, file, class, and function. Remote URLs are parsed from git remote -v and support Azure DevOps (dev.azure.com and legacy visualstudio.com) and GitHub remotes.
HTML Report
The generated report is a self-contained HTML file (inline CSS + JS, no external dependencies) that includes:
Summary table -- total repos, files, functions, and flagged counts as a plain numbers breakdown. Repository ranking -- all repos ranked by a weighted concern score (worst first), sortable and filterable. Per-repository details -- for each repo with flagged functions: distribution bar charts for function length and complexity, followed by combined risk, long functions, and high complexity tables. All tables are sortable and filterable.
Metrics
Cyclomatic Complexity
Each of the following adds 1 to the complexity score (starting from a base of 1):
| Construct | Example |
|---|---|
if |
if (x > 0) |
else if |
else if (x < 0) |
case |
case 1: |
| Switch expression arm | 1 => "one" |
for |
for (int i = 0; ...) |
foreach |
foreach (var x in items) |
while |
while (condition) |
do |
do { ... } while (...) |
catch |
catch (Exception) |
&& |
a && b |
\|\| |
a \|\| b |
?? |
x ?? defaultValue |
?. |
obj?.Property |
?: |
x ? a : b |
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.