RuboCop 不会忽略
schema.rb
文件,尽管将其 YAML
文件配置为排除它。
以下是文件的代码
.rubocop.yml
.
schema.rb
?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
...
我知道这是一个老问题,但万一有人还有类似的问题:
当指定多个扩展如
rubocop-rails
和rubocop-performance
时,将它们作为数组提供给require:
指令,例如:
require:
- rubocop-rails
- rubocop-performance
另外值得注意的是
rubocop-rails
现在默认忽略db/schema.rb
(自版本2.4.1)。
就我而言,我只添加了
AllCops:
Excludes:
- config/unicorn.rb
- db/**
Style/Documentation:
...
rubocop 成功了
万一有人有同样的困惑..在我的情况下,这实际上不是 Rubocop 问题。运行
rails db:migrate
导致重新创建架构并调整列位置。