Skip to content
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

Quiet mode? (suppress all output when no offenses) #1583

Closed
dhempy opened this issue Jan 20, 2015 · 12 comments
Closed

Quiet mode? (suppress all output when no offenses) #1583

dhempy opened this issue Jan 20, 2015 · 12 comments

Comments

@dhempy
Copy link
Contributor

dhempy commented Jan 20, 2015

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.

@Koronen
Copy link
Contributor

Koronen commented Jan 20, 2015

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?

@dhempy
Copy link
Contributor Author

dhempy commented Jan 20, 2015

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.

@dhempy
Copy link
Contributor Author

dhempy commented Jan 23, 2015

$ 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)

@bbatsov
Copy link
Collaborator

bbatsov commented Jul 28, 2015

Closing due to lack of activity.

@pvdb
Copy link

pvdb commented Oct 6, 2017

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.

@Drenmi
Copy link
Collaborator

Drenmi commented Oct 6, 2017

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

1 file inspected, no offenses detected

Correct, @pvdb?

@pvdb
Copy link

pvdb commented Oct 7, 2017

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

@Drenmi
Copy link
Collaborator

Drenmi commented Oct 7, 2017

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

@Drenmi Drenmi reopened this Oct 7, 2017
@dhempy
Copy link
Contributor Author

dhempy commented Oct 9, 2017

If you want to build on/steal/mutate Issue #1593 , feel free!

@pvdb
Copy link

pvdb commented Oct 10, 2017

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.

@derekcannon
Copy link

I am writing a Rails generator that uses Rubocop to clean up the file output before it generates the files. It would be helpful to have an option to suppress ALL the output.

@shamess
Copy link

shamess commented Aug 20, 2024

Another use case: I run Rubocop in guard, and would like it to not output anything when the successful. No need to push away my failing test output.

Update: Ahh! bundle exec rubocop --format quiet Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants