crap-analyzer

Solid

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".

Testing & QA 98 stars 6 forks Updated today MIT

Install

View on GitHub

Quality Score: 85/100

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

Skill Content

# CRAP Analyzer CRAP (Change Risk Anti-Patterns) flags functions that are both **complex** and **poorly tested** — the worst-risk code to ship. ``` CRAP(m) = comp(m)² × (1 − cov(m))³ + comp(m) ``` This skill scopes analysis to a diff, ranks findings worst-first, and turns each finding into a concrete refactor + test-stub proposal. ## Workflow 1. **Determine the diff.** First that works: - `gh pr diff` / `gh pr diff <number>` if a GitHub PR is referenced. - `git diff --merge-base <main-branch>` — detect the main branch with `git remote show origin | grep 'HEAD branch'`. - `git diff --cached` for staged changes. - `git diff HEAD~N..HEAD` for a named commit range. - Explicit file list if the user names files. Pipe the diff to `scripts/compute_crap.py --diff -`. 2. **Locate or generate coverage.** Let the script auto-discover coverage files first (lcov, Cobertura, JaCoCo, Clover, Go `coverage.out`, coverage.py JSON). If nothing is found, follow [references/coverage-discovery.md](references/coverage-discovery.md) to detect the toolchain, then ask before running it. On decline, proceed with coverage=0% and flag it in the report header. 3. **Run the analyzer.** ```bash python3 <skill-dir>/scripts/compute_crap.py --diff - --repo-root <repo> --threshold <N> --format both ``` Default threshold is 20. Read `.crap-analyzer.json` at repo root if present and pass its `threshold` through. Full flag list and output JSON shape: [references/script-referenc...

Details

Author
swingerman
Repository
swingerman/disciplined-agentic-engineering
Created
3 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Related Skills