Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mehen.ophi.dev/llms.txt

Use this file to discover all available pages before exploring further.

mehen top-offenders walks one or more paths, computes head-only metrics, and emits a deterministic sorted list of the worst-offending files. It is the right tool for repository health dashboards, prioritization reports, and “where do we spend time?” planning.
mehen top-offenders [OPTIONS] --metric <METRICS> <PATHS>...
ArgumentDescription
<PATHS>...One or more files or directories to analyze.
FlagDefaultDescription
-M, --metric <METRICS>requiredMetric to rank by. Repeatable — first is primary key, next breaks ties, etc. Prefix with + for higher-is-better or - for lower-is-better.
--max-results <N>10Maximum number of offenders to return.
-O, --output-format <FMT>markdownmarkdown or json.
-I, --include <GLOB>Glob to include files. Repeatable.
-X, --exclude <GLOB>Glob to exclude files. Repeatable.
-j, --num-jobs <N>platform defaultNumber of parser jobs.
-l, --language-type <LANG>autoLanguage type override (skip auto-detection).

Known metric names

cyclomatic, cognitive, nom.functions, loc.lloc, mi.original, mi.sei, mi.visual_studio, halstead.volume, abc, plus the full Markdown family from Markdown metrics.

Polarity

Each metric has a default direction. mehen knows that higher cognitive complexity is worse, higher maintainability index is better, etc. Override with the prefix:
  • --metric +mi.visual_studio — rank highest MI first (best at top).
  • --metric -cognitive — rank highest cognitive first (worst at top).
  • --metric cognitive — same as -cognitive because cognitive’s default polarity is “lower is better”.

Examples

mehen top-offenders src --metric cognitive --max-results 20

Determinism

The output ordering is fully deterministic: same paths, same metrics, same head ref → byte-identical report. Tie-breaking falls back to the next --metric, then to the repository-relative path. There is no sampling and no file-system-order dependence.

Exit codes

CodeMeaning
0Success.
1IO, parser-fatal, or unsupported-language error.

See also