crap-score

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

1|Updated Jul 27, 2026
One-click install
npx skills add https://github.com/FittyAr/Cardscape --skill crap-score-fittyar
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: crap-score
Source: https://github.com/FittyAr/Cardscape/tree/main/.agents/skills/crap-score
Command: npx skills add https://github.com/FittyAr/Cardscape --skill crap-score-fittyar

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Identifying which .NET methods are both complex and undertested is difficult 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 pinpoint risky code and prioritize testing or refactoring efforts. ## Core Features & Use Cases - Targeted CRAP Calculation: Computes the CRAP score (complexity² × (1 - coverage)³ + complexity) for a specific method, class, or file using Cobertura XML coverage data. - Risk Classification: Sorts methods into Low, Moderate, High, and Critical risk tiers with a ranked results table and top-offender summary. - Actionable Recommendations: Calculates the exact coverage needed to bring a method below a CRAP threshold, or flags methods that must be refactored because coverage alone cannot help. - Use Case: After a sprint, ask for the CRAP score of OrderService to discover that ProcessOrder has a score of 28.4 and needs coverage raised from 45% to 72% before release. ## Quick Start Calculate the CRAP score for the ProcessOrder method in OrderService.cs using the latest test coverage data.

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 coverage collection to produce a Cobertura XML report, then compute cyclomatic complexity by counting decision points in the method. Apply the formula CRAP = complexity² × (1 - coverage)³ + complexity using the method's line-rate from the coverage data.

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

A CRAP score below 5 indicates simple, well-tested code, while 5-15 is acceptable for most methods. Scores of 15-30 are high risk needing more tests or simplification, and anything above 30 is critical and should be refactored and covered urgently.

Which coverage tools work with CRAP score analysis in .NET?▼

The analysis works with Cobertura XML output from coverlet.collector via dotnet test --collect:"XPlat Code Coverage", or from Microsoft.Testing.Extensions.CodeCoverage on .NET 9 and later using the --coverage-output-format cobertura option.

Why do method names not match between Cobertura XML and source code?▼

Cobertura XML may use compiler-generated names for async methods, lambdas, and local functions, causing mismatches with source names. Match methods by line ranges instead of names when the identifiers do not align.

When should I not use CRAP score analysis?▼

Avoid CRAP analysis for project-wide coverage diagnosis, coverage plateau investigation, or deciding where to add tests across an entire solution. It is designed for targeted assessment of a named method, class, or file, not broad coverage planning.

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

No. When cyclomatic complexity is 15 or higher, the minimum possible CRAP score equals the complexity itself, so coverage alone cannot bring it below the threshold. The method must first be refactored, for example by extracting sub-methods, to reduce complexity.