crap-score

Calculates CRAP scores for .NET methods by combining Cobertura coverage data with cyclomatic complexity analysis.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/Netcodr81/kinetic-reports --skill crap-score-netcodr81
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: crap-score
Source: https://github.com/Netcodr81/kinetic-reports/tree/main/.github/skills/crap-score
Command: npx skills add https://github.com/Netcodr81/kinetic-reports --skill crap-score-netcodr81

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Identifying which .NET methods are risky because they are both complex and undertested is hard when looking at coverage percentages alone. This Skill computes CRAP (Change Risk Anti-Patterns) scores for a named method, class, or source file so you can prioritize testing and refactoring efforts objectively. ## Core Features & Use Cases - Targeted CRAP Calculation: Computes CRAP scores for a specific method, class, or single source file using the formula comp^2 x (1 - cov)^3 + comp. - Coverage Collection Guidance: Detects the coverage package in the test project (coverlet.collector or Microsoft.Testing.Extensions.CodeCoverage) and runs the correct dotnet test command to produce Cobertura XML. - Actionable Recommendations: Reports risk tiers, top offenders, quick wins, and the exact coverage needed to bring a method below a CRAP threshold, or flags methods that must be refactored first. - Use Case: Ask for the CRAP score of OrderService.ProcessOrder and receive a sorted table of methods with complexity, coverage, CRAP score, risk level, and specific suggestions such as raising coverage from 45% to 72%. ## Quick Start Calculate the CRAP score for the ProcessOrder method in OrderService.cs and tell me which methods need tests or refactoring first.

Frequently Asked Questions about crap-score

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I calculate CRAP score for a .NET method?▼

Run dotnet test with Cobertura coverage collection, then combine each method's cyclomatic complexity with its line coverage using CRAP = comp^2 x (1 - cov)^3 + comp. This Skill automates the full workflow for a named method, class, or file.

What is a good CRAP score threshold for C# code?▼

A CRAP score below 5 is low risk, 5-15 is moderate, 15-30 is high, and above 30 is critical. A method with 100% coverage has CRAP equal to its cyclomatic complexity, which is the minimum possible value.

Does CRAP score analysis work with coverlet and Microsoft.Testing.Extensions.CodeCoverage?▼

Yes, both coverage packages are supported. coverlet.collector uses dotnet test --collect:"XPlat Code Coverage", while Microsoft.Testing.Extensions.CodeCoverage uses --coverage --coverage-output-format cobertura, with slightly different syntax on .NET 9 versus .NET 10+.

Why do method names in Cobertura XML not match my source code?▼

Cobertura XML may use compiler-generated names for async methods, lambdas, or local functions. When names do not align, match methods by their line ranges in the coverage data instead of by name.

When should I not use CRAP score analysis?▼

Do not use it for project-wide coverage analysis, diagnosing stuck coverage, or deciding where to add tests across a whole project. It is also not for writing or running tests without the CRAP context; it targets a specific method, class, or file.

Can increasing test coverage always lower a high CRAP score?▼

No. When cyclomatic complexity is 15 or higher, the minimum possible CRAP score already meets or exceeds the threshold even at 100% coverage. Such methods must be refactored to reduce complexity before testing can help.