Rubocop: Quiet mode? (suppress all output when no offenses)

Created on 20 Jan 2015  路  10Comments  路  Source: rubocop-hq/rubocop

Is there a way to have rubocop output nothing if no offenses are found?

I'm going to write a formatter to do this, but it seems like this would be a good command line option.

If I've overlooked this functionality already in rubocop, please let me know.

Most helpful comment

If you want to build on/steal/mutate Issue https://github.com/bbatsov/rubocop/pull/1593 , feel free!

All 10 comments

What's the use case for such an option?

One alternate solution I see is to redirect all output to a file and later read it if necessary. You can check RuboCop's exit code to see if there were any offences.

rubocop > /tmp/rubocop.log
[ $? -ne 0 ] && cat /tmp/rubocop.log

EDIT: I believe outputting nothing if the program ran successfully matches the UNIX philosophy. Is that why you want this flag?

Aside from a unix-y aesthetic of "succeed quietly," I want to alias rspec on my dev box to also run rubocop. (Because I never remember to run it on my own!) So I want it to nag me about formatting ASAP, but I don't want to see the clutter when I'm a good boy.

$ rubocop -V
warning: parser/current is loading parser/ruby21, which recognizes
warning: 2.1.5-compliant syntax, but you are running 2.1.4.
0.28.0 (using Parser 2.2.0.2, running on ruby 2.1.4 x86_64-darwin14.0)

Closing due to lack of activity.

The other use case is when using rubocop in git pre-commit hooks... without any offenses, you don't really want to see any output, as that's just noise... "succeed quietly" indeed, as @dhempy so correctly pointed out.

So basically --format simple, but you also want to suppress the final:

1 file inspected, no offenses detected

Correct, @pvdb?

Exactly that, @Drenmi -- "succeed completely quietly", to paraphrase @dhempy :smile:

Reopening due to renewed interest. Might take a stab at it tonight.

If you want to build on/steal/mutate Issue https://github.com/bbatsov/rubocop/pull/1593 , feel free!

For context, the "succeed quietly" guideline @dhempy was referring to is also known as "The Rule of Silence", a long-standing, KISS-inspired design rule part of the Unix philosophy:

Rule of Silence

Developers should design programs so that they do not print unnecessary output. This rule aims to allow other programs and developers to pick out the information they need from a program's output without having to parse verbosity.

Was this page helpful?
0 / 5 - 0 ratings