Skip to main content
Reference tooling 4 min read Updated

minikin-cargo-crap-main-docs-reference-cli

Command line

Flags

FlagDefaultPurpose
--lcov \<FILE\>noneLCOV file from cargo llvm-cov or cargo tarpaulin.
--path \<DIR\>.Root to walk for .rs files (respects .gitignore).
--threshold \<N\>30Score above which a function is flagged.
--min \<SCORE\>noneHide entries below this score.
--top \<N\>noneShow only the N worst offenders.
--sort {crap,file}crapFinal ordering of entries.
--missing {pessimistic,optimistic,skip}pessimisticHow to score a function with no coverage data.
--exclude \<GLOB\>noneSkip files matching this pattern (repeatable).
--no-default-excludesoffAnalyze tests/**, benches/** and examples/** as well.
--allow \<GLOB\>noneHide matching functions from the report (repeatable).
--duplicatesoffAlso report candidate duplicate functions.
--dup-threshold \<SCORE\>0.82Similarity at or above which a duplicate pair is reported.
--format {human,json,github,markdown,pr-comment,sarif,shields}humanOutput format.
--summaryoffPrint aggregate stats instead of the per-function table.
--workspaceoffAnalyze every Cargo workspace member.
-p, --package \<NAME\>noneAnalyze only the named workspace member(s), repeatable.
--fail-aboveoffExit 1 if any function exceeds --threshold.
--baseline \<FILE\>noneJSON from a previous --format json run; turns on delta mode.
--fail-regressionoffExit 1 if any function’s score increased since --baseline.
--show-unchangedoffAlso list Unchanged rows in --baseline mode.
--epsilon \<VALUE\>0.01Tolerance of the regression detector.
--jobs \<N\>host CPUsCap parallel source-file analysis at N threads.
--no-cacheoffParse every file afresh; neither read nor write the analysis cache.
--output \<FILE\>noneWrite output to FILE instead of stdout.
--repo-url \<URL\>noneRepo base URL for clickable source links.
--commit-ref \<REF\>noneCommit SHA or branch those links point at.

Notes on flags

See Output formats for the seven --format renderers.

--exclude and --allow hide code at different stages. --exclude skips files at walk time, so they are never parsed, and ** crosses directory boundaries. Its globs are relative to --path. In --workspace and -p mode they match a file’s path below its member’s directory and its path below the workspace root, so both src/generated/** (in every member) and agent/** (one whole member) work. An --exclude glob that excludes no file gets a warning on stderr; the exit code does not change. --allow analyzes the file and drops matching functions from the report. An --allow entry containing / or ** is a path glob matched against the file a function lives in (src/generated/**); anything else matches the function name, where * crosses :: (Foo::*). Both flags are repeatable, and --exclude appends to the default exclusions instead of replacing them.

--sort crap sorts by score descending, which reads best top-down. --sort file sorts by (file, function, line) ascending, which is stable across score changes, so a committed JSON baseline produces minimal diffs. --top always selects the N highest-CRAP functions first, and --sort then reorders what survived. The ordering applies to every format.

The human table shows every function above the threshold and only the 10 highest-scoring below it. --top or --min turns that cap off, and so does --show-unchanged with --baseline. See The human table’s cap.

With --baseline, --top and --min choose only the rows shown: the comparison, the Removed list, the summary line and --fail-regression still cover every function. See Regression gate.

--summary replaces the per-function table with the total, the crappy count and the worst offender. Under --workspace or -p/--package it prints the per-crate summary above that aggregate line. json and github stay machine-readable and are unaffected.

See Workspaces and changed-package CI for --workspace and -p/--package.

--jobs caps the source-file analysis pool, which matters in memory-constrained CI and Docker environments. Without it, rayon sizes the pool from the host. A --jobs of zero, a negative --epsilon and a --dup-threshold outside 0.0..=1.0 are all rejected before analysis starts, with exit code 2.

Colour in the human and --summary formats is automatic, enabled only when writing to a terminal and never into an --output file or a pipe. Set NO_COLOR=1 to disable colour unconditionally, or FORCE_COLOR=1 to force it on (e.g. for | less -R). NO_COLOR wins when both are set.

The --missing policy

Some functions have complexity data but no coverage data: the coverage tool didn’t instrument them, or they were excluded via #[cfg(test)], or the coverage run was scoped to a subset of the workspace. Three policies:

  • pessimistic (default): treat as 0% covered. Surfaces unmapped code as a red flag. Correct for CI gates.
  • optimistic: treat as 100% covered. Useful during local development when you’re iterating on a specific module.
  • skip: drop the row entirely.