问题
Am looking at rubocop but want to start with warnings and errors - we'll get to convention-related alerts later. My question is: how do I invoke rubocop where it will ignore convention-related alerts and only report on Warning, error & fatal messages.
Thanks Michael.
回答1:
rubocop --only Syntax,Lint
From https://github.com/bbatsov/rubocop/issues/2337#issuecomment-150477553
If you don't have any custom severity levels in your configuration, it's quite simple. The Synax cop reports on fatal and error level, Lint cops on warning level and all other cops on convention level.
So for only fatal and error, it's rubocop --only Syntax (which is only supported on master, not released yet), and for warningand above it's rubocop --only Lint.
回答2:
Guess you need to disable them one by one. Generally speaking, I'd suggest enforce all the rules.
For your convenience, here is my .rubocop.yml I frequently used. This should suppress many non-critical warnings.
AllCops: Excludes: - Berksfile - recipes/basic.rb - attributes/*.rb # Customize rules Metrics/LineLength: Max: 95 MethodLength: Max: 35 Metrics/AbcSize: Enabled: false BlockLength: Max: 70
I constantly bump by rubocop errors and warning. Thus I've published this post.
Common Rubocop Errors: Improve Your Ruby Code Quality
来源:https://stackoverflow.com/questions/37309321/how-do-i-suppress-rubocop-conventions