microsoft/mutate4csharp
Captured source
source ↗microsoft/mutate4csharp
Description: Agentic port of https://github.com/unclebob/mutate4java
License: CC0-1.0
Stars: 0
Forks: 0
Open issues: 4
Created: 2026-07-26T19:00:19Z
Pushed: 2026-07-27T06:42:07Z
Default branch: master
Fork: no
Archived: no
README:
crap4csharp
Attribution
crap4csharp continues the lineage of Robert C. ("Uncle Bob") Martin's original crap4clj, and is a C# port of its Java sibling crap4java.
---
crap4csharp is a standalone CRAP metric tool for C# projects, modeled after crap4java.
It combines method cyclomatic complexity with Coverlet (Cobertura) method coverage and reports CRAP scores. On each run it deletes stale coverage artifacts, runs coverage, then analyzes the selected files.
Formula
CRAP = CC^2 * (1 - coverage)^3 + CC
CCis cyclomatic complexity.coverageis method coverage fraction from Cobertura line counters (the .NET analog of JaCoCo
INSTRUCTION counters).
Coverage Pipeline
For each invocation, per module (nearest .sln, else .csproj, else the project root):
1. Delete stale coverage artifacts:
coverage/
2. Run dotnet test --collect:"XPlat Code Coverage" --results-directory coverage 3. Read the produced coverage.cobertura.xml 4. Analyze the selected C# files
Build and Test
dotnet test
Run
Build:
dotnet build -c Release
From the project root you want to analyze:
dotnet run --project src/Crap4CSharp -c Release
CLI
--help Print usage to stdout (no args) Analyze all C# files under src/ --changed Analyze changed C# files under src/ Analyze only these files Analyze all C# files under each directory's src/ subtree
Examples:
dotnet run --project src/Crap4CSharp -c Release -- --help dotnet run --project src/Crap4CSharp -c Release dotnet run --project src/Crap4CSharp -c Release -- --changed dotnet run --project src/Crap4CSharp -c Release -- src/Sample.cs dotnet run --project src/Crap4CSharp -c Release -- project-a project-b
Exit codes
0success, threshold respected1invalid CLI usage, or a fatal error (e.g. no tests ran / no coverage produced — see Notes)2CRAP threshold exceeded (> 8.0)
Notes
- Fail fast: if a module runs no tests or produces no coverage,
crap4csharpexits non-zero
rather than continuing — a deliberate, stricter departure from crap4java. A method simply absent from an otherwise-populated report is still reported as N/A.
- Report output is sorted by CRAP descending, with
N/Aat the bottom.