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.
dotnet tool install -g ComplexityRipperScan a directory of repos and generate an HTML report with default thresholds (200 lines, 25 complexity):
complexityripper run --root C:\src\my-reposThis produces two files: stats.json (raw metrics) and code-complexity-report.html (the report).
--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\MyProjectcomplexityripper run --root C:\src\all-reposcomplexityripper run --root C:\src\my-repos --output my-report.html --stats my-stats.jsonFlag functions with 300+ lines or cyclomatic complexity of 20+:
complexityripper run --root C:\src\my-repos --threshold-lines 300 --threshold-complexity 20complexityripper run --root C:\src\my-repos --include "ProjectA|ProjectB"
complexityripper run --root C:\src\my-repos --exclude "Tests|Legacy"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.htmlcomplexityripper analyze --root C:\src\my-repos --output stats.jsoncomplexityripper report --input stats.json --output report.html --threshold-lines 200 --threshold-complexity 25| 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 |
| 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 |
| 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) |
| 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 |
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.
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.
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.
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 |