-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A way to sort rubocop output by files with the most violations #2481
Comments
We already have https://github.com/bbatsov/rubocop#file-list-formatter and https://github.com/bbatsov/rubocop#offense-count-formatter Guess you want some mixture of them - filename (total offences in file). |
The offense count formatter seems to be exactly what @bytenel is asking for. I suggest this can be closed. |
I think what he wants is something that could be achieved with a ruby one-liner that does some processing of JSON output. I ran the following on the RuboCop project itself: ./bin/rubocop -c config/default.yml --format json | ruby -rjson -e 'JSON.parse(ARGF.read)["files"].map { |h| [h["offenses"].size, h["path"]] }.sort.each { |count, path| printf "%4d %s\n", count, path}' and got
(worst offenders last). |
Still, this seems like a potentially useful formatter to me. |
And shouldn't be too hard to implement. Coming up with a name is the worst part. |
Just pushed a new formatter... still needs changelog and specs. |
and README. |
As requested by Ben Nelson, this formatter lists all the offensive files in the inspected project, with the most offensive ones first. Output looks like: 4 test1.rb 2 test2.rb 1 test3.rb -- 7 Total
It would be very helpful to be able to have rubocop output just the filenames of particular violators and list out how many violations the file has with them sorted by the file with the most violations in it. That way you can take care of files with the largest number of problems first!
The text was updated successfully, but these errors were encountered: