如何告诉Rubocop只看特定的目录?

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

我想只包含特定目录,并忽略其他所有目录。

这忽略了一切

AllCops:
  Include:
    - 'something/**/*.rb'

  Exclude:
    - '**/*'

这会检查一切

AllCops:
  Include:
    - 'something/**/*.rb'
ruby rubocop
2个回答
1
投票

appears,如果你定义Include,Rubocop的最新版本(~0.56 +)将只包含Include中指定的文件(或模式)。

这意味着如果您所做的只是:

AllCops:
  Include:
    - 'something/**/*.rb'

然后只会检查something/**/*.rb。它会覆盖默认文件而不是附加到它。

我认为这是新功能,因为这就是它现在为我们所做的事情,而不是之前的事情。非常欺骗小版本发布。


0
投票

正则表达似乎工作,但非常难看

AllCops:
  Exclude:
    - !ruby/regexp /^((?!(something|some\/other\/dir)).)*$/
© www.soinside.com 2019 - 2024. All rights reserved.