Documentation · Static metrics

km smells

Code smell detection

Detects common code quality issues per file using text-based heuristics (no AST required). Only languages with complexity marker support are analyzed (same set as km cycom: Rust, Python, JS/TS, C/C++, Go, etc.).

km smells [path]

Smell types

SmellDescription
long_functionFunction body exceeds --max-lines (default: 50)
long_paramsFunction has more than --max-params parameters (default: 4)
todo_debtTODO, FIXME, HACK, XXX, or BUG in comment lines
magic_numberBare numeric literals in code (excluding 0, 1, 2, -1 and const/let declarations)
commented_codeTwo or more consecutive comment lines containing code-like patterns

Options:

FlagDescription
--top NShow only the top N files by smell count (default: 20)
--max-lines NMaximum function body lines before flagging (default: 50)
--max-params NMaximum parameter count before flagging (default: 4)
--files FILEAnalyze only these specific files (repeatable). Useful for scripting
--since-ref REFAnalyze only files changed since this git ref (e.g. origin/main, HEAD~1). Ideal for CI
--format {table,json,short,terse,github,codeclimate}Output format (default: table). github emits GitHub Actions annotations; codeclimate (alias: gitlab) emits CodeClimate JSON for GitLab Code Quality

The table breaks each file’s smell count down by type, with one column per smell kind (magic, long, param, todo, comm) and a per-column total in the footer.

Example output:

Code Smells
──────────────────────────────────────────────────────────────────────
 File                            Total  magic  long  param  todo  comm
──────────────────────────────────────────────────────────────────────
 src/loc/counter.rs                 12      7     1      0     4     0
 src/main.rs                         6      2     0      0     4     0
 src/dups/detector.rs                3      0     2      1     0     0
──────────────────────────────────────────────────────────────────────
 Total (3 files)                    21      9     3      1     8     0