Documentation · Static metrics

km cogcom

Cognitive complexity

Computes cognitive complexity per file and per function using the SonarSource method (2017). Unlike cyclomatic complexity, cognitive complexity measures how difficult code is to understand, penalizing deeply nested structures and rewarding linear control flow.

km cogcom [path]

Options:

FlagDescription
--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
--include-testsInclude test files in analysis (excluded by default)
--top NShow only the top N files (default: 20)
--min-complexity NSkip files whose most complex function is below N; with --per-function, also hide functions below N (default: 1)
--per-functionShow per-function breakdown
--sort-by METRICSort by total, max, or avg (default: total)