Crap4DotNet 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global Crap4DotNet --version 0.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local Crap4DotNet --version 0.1.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Crap4DotNet&version=0.1.0
                    
nuke :add-package Crap4DotNet --version 0.1.0
                    

Crap4DotNet

A .NET global tool that computes CRAP (Change Risk Anti-Patterns) scores for your C# code.

CRAP combines cyclomatic complexity with code coverage to identify methods that are both complex and poorly tested — the riskiest code in your project.

Install

dotnet tool install -g Crap4DotNet

Usage

# Analyze a project (auto-discovers coverage from TestResults)
dotnet crap analyze ./src/MyProject

# Analyze with explicit coverage file
dotnet crap analyze ./src/MyProject --coverage ./TestResults/coverage.cobertura.xml

# Write report to file
dotnet crap analyze ./src/MyProject --output report.json

# Custom threshold (default: 30)
dotnet crap analyze ./src/MyProject --threshold 15

# Compare two reports
dotnet crap diff before.json after.json

Exit Codes

Code Meaning
0 All methods are below the CRAP threshold
1 One or more methods exceed the CRAP threshold
2 Error (missing files, parse failure, invalid config)

CRAP Formula

CRAP(m) = complexity(m)^2 * (1 - coverage(m))^3 + complexity(m)

A method with complexity 1 and full coverage has a CRAP score of 1 (perfect). A method with complexity 20 and 10% coverage has a CRAP score of ~312 (terrible).

JSON Output

The tool outputs a JSON report with method-level CRAP scores, statistics, severity bands, and a namespace hierarchy. See the specification for the full schema.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.1.1 20,240 3/13/2026
0.1.0 143 3/12/2026