My project is extending open-source classes from a third-party gem that we don't want to hold to the same coding standards as our own code. Refactoring the gem code isn't a viable option. We just want Rubocop to ignore the copied code.
我的项目是从第三方的gem中扩展开放源码类,我们不想让第三方的gem遵循与我们自己的代码相同的编码标准。重构gem代码不是一个可行的选择。我们只是希望Rubocop忽略复制的代码。
How can I instruct Rubocop to completely ignore a file or directory?
如何指示Rubocop完全忽略文件或目录?
3 个解决方案
#1
48
As per orde's comment with the link to the manual I found .rubocop.yml and added the following:
根据orde对我找到的手册链接的评论。rubocop.yml,并添加了以下内容:
AllCops:
Exclude:
- 'path/to/excluded/file.rb'
where the path is relative to .rubocop.yml
路径相对于。rubocopl。yml的位置
#2
13
For your convenience, here is the .rubocop.yml I frequently used.
为了您的方便,这是我常用的。
See formal explanation of .rubocop.yml here.
参见.rubocop.yml的正式解释。
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.
我经常遇到rubocop错误和警告。因此我发表了这篇文章。
Common Rubocop Errors: Improve Your Ruby Code Quality
常见的Rubocop错误:改进您的Ruby代码质量
#3
#1
48
As per orde's comment with the link to the manual I found .rubocop.yml and added the following:
根据orde对我找到的手册链接的评论。rubocop.yml,并添加了以下内容:
AllCops:
Exclude:
- 'path/to/excluded/file.rb'
where the path is relative to .rubocop.yml
路径相对于。rubocopl。yml的位置
#2
13
For your convenience, here is the .rubocop.yml I frequently used.
为了您的方便,这是我常用的。
See formal explanation of .rubocop.yml here.
参见.rubocop.yml的正式解释。
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.
我经常遇到rubocop错误和警告。因此我发表了这篇文章。
Common Rubocop Errors: Improve Your Ruby Code Quality
常见的Rubocop错误:改进您的Ruby代码质量