crap-analysis

Analyze code coverage and CRAP scores to identify high-risk .NET code.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill crap-analysis-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: crap-analysis
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/crap-analysis
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill crap-analysis-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Complex code without tests is risky to change, but teams often lack a systematic way to find it. This Skill combines cyclomatic complexity with test coverage into CRAP (Change Risk Anti-Patterns) scores so you can pinpoint which methods need tests or refactoring before you modify them. ## Core Features & Use Cases - CRAP Score Analysis: Calculate risk scores from complexity and coverage, with clear thresholds (under 5 low risk, over 30 high risk) to prioritize testing effort. - Coverage Collection Setup: Configure coverage.runsettings with OpenCover format, exclusion patterns for generated code, and ReportGenerator tooling for HTML Risk Hotspots reports. - CI/CD Integration: Ready-to-use GitHub Actions and Azure Pipelines workflows that collect coverage, generate reports, and post summaries to pull requests. - Use Case: Before refactoring a legacy authentication module, run the analysis to discover that ValidateToken() has a CRAP score of 32 with 0% coverage, then add tests before touching the code. ## Quick Start Analyze the test coverage and CRAP scores for my .NET solution and list the highest-risk methods that need tests.

Frequently Asked Questions about crap-analysis

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

FAQPage Schema
How do I calculate CRAP scores for .NET code?▼

CRAP score equals complexity multiplied by (1 - coverage) squared. Collect coverage in OpenCover format using XPlat Code Coverage, then generate a ReportGenerator HTML report whose Risk Hotspots section lists methods sorted by complexity and CRAP score.

What is a good CRAP score threshold for code quality?▼

Scores under 5 indicate well-tested low-risk code, 5 to 30 is acceptable but worth monitoring, and above 30 is high risk requiring tests or refactoring. New code should stay under 30, with line coverage above 80% and branch coverage above 60%.

Why do I need OpenCover format for coverage reports?▼

OpenCover format includes cyclomatic complexity metrics, which are required for CRAP score calculation. Configure it in coverage.runsettings by setting the Format element to include opencover alongside cobertura.

How do I add coverage reports to GitHub Actions pull requests?▼

Run dotnet test with the XPlat Code Coverage collector, generate a MarkdownSummaryGithub report with ReportGenerator, then post it to the PR using the marocchino/sticky-pull-request-comment action with the summary file path.

What code should be excluded from coverage analysis?▼

Exclude test and benchmark assemblies, source-generated files like .g.cs and .designer.cs, Blazor generated code, EF Core migrations, and members marked with GeneratedCode, CompilerGenerated, or ExcludeFromCodeCoverage attributes. SkipAutoProps removes trivial auto-property branches.