How do I suppress Rubocop Conventions?

痞子三分冷 提交于 2019-12-11 07:34:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!