crap4cljlisted
Install: claude install-skill unclebob/crap4clj
# crap4clj — CRAP Metric for Clojure
Computes the **CRAP** (Change Risk Anti-Pattern) score for every `defn` and `defn-` in a Clojure project. CRAP combines cyclomatic complexity with test coverage to identify functions that are both complex and under-tested.
## Setup
Add both a `:cov` alias (Cloverage) and a `:crap` alias to the project's `deps.edn`:
```clojure
:cov {:extra-deps {cloverage/cloverage {:mvn/version "1.2.4"}}
:main-opts ["-m" "speclj.cloverage" "--" "-p" "src" "-s" "spec"]}
:crap {:extra-deps {io.github.unclebob/crap4clj
{:git/url "https://github.com/unclebob/crap4clj"
:git/sha "<current-sha>"}}
:main-opts ["-m" "crap4clj.core"]}
```
The example above uses `speclj.cloverage` as the runner. For `clojure.test` projects, use `cloverage.coverage` instead:
```clojure
:cov {:extra-deps {cloverage/cloverage {:mvn/version "1.2.4"}}
:main-opts ["-m" "cloverage.coverage" "-p" "src" "-s" "test"]}
```
Adjust the `-p` (source path) and `-s` (test path) flags in `:cov` to match your project layout.
## Usage
```bash
# Analyze all source files under src/
clj -M:crap
# Filter to specific modules
clj -M:crap combat movement
```
crap4clj automatically deletes stale coverage reports, runs `clj -M:cov`, and then analyzes the results.
### Output
A table sorted by CRAP score (worst first):
```
CRAP Report
===========
Function Namespace CC Cov% CRAP
--