mix crap (ex_crap v0.1.0)

Copy Markdown View Source

Prints CRAP scores for Elixir source files and fails when results exceed the configured threshold.

Usage: mix crap

mix test --cover --export-coverage default
mix crap
mix crap --coverdata path/to/file.coverdata
mix crap --max-score 30
mix crap --path path/to/source
mix crap --verbose

Coverage workflow: mix crap consumes persisted Mix/Erlang coverage data. The default path is cover/default.coverdata, produced by mix test --cover --export-coverage default. Plain mix test --cover prints a coverage report, but does not leave importable coverage data for a later mix crap run.

The task scans root lib/**/*.ex files by default (default: lib). Use --path PATH to scan another source directory as PATH/**/*.ex. It skips valid files with no analyzable function or macro bodies, such as callback-only protocols and behaviour modules. The default maximum CRAP score is 30 (default: 30). Use --max-score N to override it. The task fails when any function exceeds the threshold or has score calculation errors. Missing function coverage is scored as 0%. Missing coverdata input is a usage error when analyzable functions exist. Use --verbose to print the full scored table on passing runs.