Code quality crap

From macalbert/envilder · View interactive version

Code quality crap is an AI agent skill from the GitHub repository macalbert/envilder. CRAP score quality gate for code complexity and test coverage. Use when reviewing methods for complexity risk, deciding whether to split methods, or interpreting complexity and coverage risk without manufacturing tests.

How to use this skill

Skill file

Code Quality: CRAP Score

CRAP (Change Risk Anti-Patterns) measures the risk of a method based on

cyclomatic complexity and test coverage.

When to Use

Formula

$$\text{CRAP}(m) = \text{comp}(m)^2 \times (1 - \text{cov}(m))^3 + \text{comp}(m)$$

Where:

Quality Gate

Every method MUST have a CRAP score below 6.

Coverage Thresholds

These thresholds are intentionally stricter than the mathematical minimum,

providing a safety margin:

| Complexity | Recommended coverage for CRAP < 6 |

|-----------|-----------------------------------|

| 1 | 0% (any) |

| 2 | > 0% |

| 3 | 40%+ |

| 4 | 60%+ |

| 5 | 80%+ |

| 6+ | Not achievable: must split to reduce complexity |

Actions by Scenario

| Scenario | Action |

|----------|--------|

| CRAP >= 6 due to high complexity | Extract complex branches into smaller methods |

| CRAP >= 6 due to low coverage | First reduce complexity; if important behavior lacks evidence, route a separate verification contract rather than adding coverage-only tests |

| Complexity 6+ regardless of coverage | Must split: CRAP floor equals complexity |

Severity Classification

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.