- Home
- Skills
- Aaronontheweb
- Dotnet Skills
- Crap Analysis
crap-analysis_skill
- Shell
643
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill aaronontheweb/dotnet-skills --skill crap-analysis- SKILL.md11.3 KB
Overview
This skill analyzes code coverage and CRAP (Change Risk Anti-Patterns) scores to pinpoint high-risk .NET code. It expects OpenCover-format coverage data and uses ReportGenerator to produce Risk Hotspots showing cyclomatic complexity, NPath, and untested paths. The output highlights methods that need tests or refactoring so teams can prioritize work.
How this skill works
The skill ingests OpenCover XML produced by dotnet test with the XPlat code coverage collector. It calculates CRAP = Complexity x (1 - Coverage)^2 for each method and generates an HTML Risk Hotspots report with ReportGenerator. The report sorts methods by risk and includes complexity, coverage percentages, and CRAP scores to drive remediation decisions.
When to use it
- Before merging changes to identify risky code in pull requests
- When setting or enforcing coverage thresholds in CI/CD
- During refactoring to ensure complex code has tests
- While prioritizing test work for legacy codebases
- When validating coverage collection uses OpenCover format
Best practices
- Require OpenCover format in coverage.runsettings to capture complexity metrics
- Exclude test/benchmark/generated assemblies and auto-properties to reduce noise
- Enforce line/branch coverage and CRAP thresholds in CI (e.g., Line>80%, Branch>60%, CRAP<30)
- Treat CRAP>30 and low coverage as immediate test/refactor candidates
- Use Risk Hotspots to focus tests on complex, low-coverage methods rather than trivial code
Example use cases
- Add a GitHub Action job that runs tests, produces OpenCover XML, runs ReportGenerator, and posts SummaryGithub.md to the PR
- Scan legacy modules to create a prioritized list of methods with CRAP>30 for targeted test efforts
- Fail CI if Line or Branch coverage drops below configured coverage.props thresholds
- Generate HTML Risk Hotspots for a release review to decide which modules need backfill tests
FAQ
OpenCover includes cyclomatic and NPath complexity metrics required to compute CRAP scores; other formats often omit these values.
What CRAP score is considered dangerous?
Treat CRAP scores above 30 as high risk; prioritize tests or refactoring for those methods, especially if coverage is low.