feat: ruff --statistics
adds --statistics flag from issue #1814 open to all feedback :)
A few thoughts that come to mind...
Would it be possible to provide the following additional flags?
--statistics-sort-fieldacceptingcount(default) andcode--statistics-sort-orderwithascanddesc(default)
Would it make sense to split the code into a separate column to the description? In future additional columns could be possibly be added to the stats via --statistics-fields... For example, filename could be added to have a breakdown by file.
What about also accepting --statistics-format where there could be text (default), json, jsonl, etc.?
I guess these could be farmed out to separate issues to break this down into smaller chunks, but the sorting should be relatively straightforward to add here?
I'd love to try and output in a format that's amenable to doing those kinds of transforms in a downstream tool, e.g. with Unix-style piping, rather than implement all the flags and options in Ruff itself. For example: --format=json is intended to work here, so users could always output as JSON then sort and filter themselves. But maybe there's a way to output standard tabular data that can be manipulated in that way too? I'd have to look at what some other, comparable tools for inspiration.
I tried using it and currently get:
error[E0425]: cannot find value `cli` in this scope
--> ruff_cli/src/args.rs:436:15
|
436 | } else if cli.statistics {
| ^^^ not found in this scope
should be args.statistics
FYI: as I am using this heavily I used your WIP version and rebased onto latest main: https://github.com/spaceone/ruff/pull/new/statistics (in case you want to continue working on it without resolving the merge conflicts on your own).
Closing in favor of #2284 -- which just merged!