Skip to content
Latchkey

ruff check --statistics: Count Violations

ruff check --statistics prints a table of how many times each rule was violated, instead of listing every occurrence.

When a fresh codebase floods CI with violations, --statistics turns the noise into a ranked list so you know which rules to fix or ignore first.

What it does

ruff check --statistics aggregates violations and prints, per rule code, the count and whether the rule is fixable. It is a summary view for triage, not a per-line report. The exit code still reflects whether violations remain.

Common usage

Terminal
ruff check --statistics .
# combine with a selection to scope the count
ruff check --select ALL --statistics .
# machine-readable counts
ruff check --statistics --output-format json .

Flags

FlagWhat it does
--statisticsPrint per-rule violation counts
--select <codes>Scope the statistics to chosen rules
--output-format jsonEmit the counts as JSON
[*] markerIndicates the rule is autofixable

In CI

Run --statistics once when adopting Ruff to decide which rules to enable, ignore, or fix in bulk. It is a triage tool; keep the gating job as a plain ruff check . so the exit code still fails on violations.

Common errors in CI

Expecting per-file output and getting only counts means --statistics is doing its job; drop it for line-level detail. The exit code is unchanged, so a statistics run on dirty code still exits 1. A count that looks too high after an upgrade reflects new rules joining the selection, not a code regression.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →