crap-score

Solid

Calculates CRAP (Change Risk Anti-Patterns) score for .NET methods, classes, or files. Use when the user asks to assess test quality, identify risky untested code, compute CRAP scores, or evaluate whether complex methods have sufficient test coverage. Requires code coverage data (Cobertura XML) and cyclomatic complexity analysis. DO NOT USE FOR: writing tests, general test execution unrelated to coverage/CRAP analysis, or general code coverage reporting without CRAP context.

Data & Documents 3,196 stars 237 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# CRAP Score Analysis Calculate CRAP (Change Risk Anti-Patterns) scores for .NET methods to identify code that is both complex and undertested. ## Background The CRAP score combines **cyclomatic complexity** and **code coverage** into a single metric: $$\text{CRAP}(m) = \text{comp}(m)^2 \times (1 - \text{cov}(m))^3 + \text{comp}(m)$$ Where: - $\text{comp}(m)$ = cyclomatic complexity of method $m$ - $\text{cov}(m)$ = code coverage ratio (0.0 to 1.0) of method $m$ | CRAP Score | Risk Level | Interpretation | |------------|------------|----------------| | < 5 | Low | Simple and well-tested | | 5-15 | Moderate | Acceptable for most code | | 15-30 | High | Needs more tests or simplification | | > 30 | Critical | Refactor and add coverage urgently | A method with 100% coverage has CRAP = complexity (the minimum). A method with 0% coverage has CRAP = complexity^2 + complexity. ## When to Use - User wants to assess which methods are risky due to low coverage and high complexity - User asks for CRAP score of specific methods, classes, or files - User wants to prioritize which code to test next - User wants to evaluate test quality beyond simple coverage percentages ## When Not to Use - User just wants to run tests (use `run-tests` skill) - User wants to write new tests (use `writing-mstest-tests` skill or general coding assistance) - User only wants a coverage percentage without complexity analysis ## Inputs | Input | Required | De...

Details

Author
dotnet
Repository
dotnet/skills
Created
3 months ago
Last Updated
yesterday
Language
C#
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

Testing & QA Solid

coverage-analysis

Automated, project-wide code coverage and CRAP (Change Risk Anti-Patterns) score analysis for .NET projects with existing unit tests. Auto-detects solution structure, runs coverage collection via `dotnet test` (supports both Microsoft.Testing.Extensions.CodeCoverage and Coverlet), generates reports via ReportGenerator, calculates CRAP scores per method, and surfaces risk hotspots — complex code with low test coverage that is dangerous to modify. Use when the user wants project-wide coverage analysis with risk prioritization, coverage gap identification, CRAP score computation across an entire solution, or to diagnose why coverage is stuck or plateaued and identify what methods are blocking improvement. DO NOT USE FOR: targeted single-method CRAP analysis (use crap-score skill), writing tests, general test execution unrelated to coverage/CRAP analysis, or coverage reporting without CRAP context.

3,196 Updated yesterday
dotnet
Testing & QA Listed

crap-analyzer

Use to produce a risk-based refactor + test plan for recently-changed code on a diff/branch/PR by computing CRAP (complexity × untested) on changed methods. Multi-language — TypeScript, JavaScript, Python, Java, Kotlin, Go, Ruby, C#, Rust, PHP — auto-discovers how the repo generates coverage. Triggers — "/crap-analyzer", "analyze CRAP", "compute CRAP", "find risky methods", "find complex untested methods".

99 Updated 2 days ago
swingerman
Data & Documents Listed

crap4clj

Use when the user asks for a CRAP report, cyclomatic complexity analysis, or code quality metrics on a Clojure project

26 Updated 3 weeks ago
unclebob
AI & Automation Listed

codebase-health

Score your codebase 0-100 across complexity, coupling, cohesion, test coverage, documentation, churn hotspots, dependency health, and lint/type safety. Use when: 'how healthy is this codebase', 'check code quality', 'score my project', 'find tech debt hotspots', 'codebase assessment', 'what needs attention in this repo', 'health check', 'quality audit'.

4 Updated today
tinh2
Testing & QA Solid

code-maturity-assessor

Systematic code maturity assessment using Trail of Bits' 9-category framework. Analyzes codebase for arithmetic safety, auditing practices, access controls, complexity, decentralization, documentation, MEV risks, low-level code, and testing. Produces professional scorecard with evidence-based ratings and actionable recommendations.

5,487 Updated 3 days ago
trailofbits