为什么 RuboCop 在 Rails 中不能忽略 'schema.rb' 文件?

8

RuboCop不会忽略文件schema.rb,尽管已经配置了其YAML文件以排除它。

我该如何配置以忽略schema.rb?

以下是来自文件.rubocop.yml的代码片段:

require: rubocop-rails
require: rubocop-performance

AllCops:
  Exclude:
    - 'db/**/*'
    - 'config/**/*'
    - 'script/**/*'
    - 'bin/{rails,rake}'
    - 'vendor/**/*'
    - 'spec/fixtures/**/*'
    - 'tmp/**/*'
    - 'Gemfile.lock'

Rails:
  Enabled: true

Layout/SpaceAroundEqualsInParameterDefault:
  EnforcedStyle: no_space

Naming/VariableNumber:
  EnforcedStyle: normalcase

Style/StringLiterals:
  EnforcedStyle: double_quotes

Style/SymbolArray:
  Enabled: true

1
请问您能否包含 rubocop --debug 的一些或全部输出?顶部列出的活动配置文件部分将非常有帮助,与您的 db 文件夹相关的“扫描”行也是如此。 - Jared Beck
3个回答

3

rubocop-rails现在自动忽略db/schema.rb。这是在版本2.4.1中引入的。

此外,不应该为每个RuboCop扩展使用单独的require语句,而是应该将它们作为数组提供,以确保加载所有扩展。例如:

require:
    - rubocop-rails
    - rubocop-performance

0

在我的情况下,我只添加了

AllCops:
  Excludes:
    - config/unicorn.rb
    - db/**

Style/Documentation:
...

而且 Rubocop 已经工作了


0
如果有人有同样的困惑...在我的情况下,这实际上不是Rubocop的问题。运行rails db:migrate会导致模式被重新创建并调整列位置。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接