为什么 RuboCop 不忽略 Rails 中的文件“schema.rb”?

问题描述 投票:0回答:3

RuboCop 不会忽略

schema.rb
文件,尽管将其
YAML
文件配置为排除它。

以下是文件的代码

.rubocop.yml
.

如何配置 RuboCop 以忽略
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

...
ruby-on-rails ruby yaml rubocop
3个回答
1
投票

我知道这是一个老问题,但万一有人还有类似的问题:

当指定多个扩展如

rubocop-rails
rubocop-performance
时,将它们作为数组提供给
require:
指令,例如:

require:
  - rubocop-rails
  - rubocop-performance

另外值得注意的是

rubocop-rails
现在默认忽略
db/schema.rb
(自版本2.4.1)。


0
投票

就我而言,我只添加了

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

Style/Documentation:
...

rubocop 成功了


0
投票

万一有人有同样的困惑..在我的情况下,这实际上不是 Rubocop 问题。运行

rails db:migrate
导致重新创建架构并调整列位置。

© www.soinside.com 2019 - 2024. All rights reserved.