Rubocop:如何从度量标准中排除文件名模式?

时间:2016-06-22 12:31:20

标签: rubocop

我想在Rubocop中为全局匹配*_spec.rb(Serverspec文件)的文件名禁用行长度检查。

我尝试按以下方式将Exclude添加到config/default.yml,但它不起作用(没有错误,检测到攻击):

Metrics/LineLength:
  Max: 80
  AllowHeredoc: true
  AllowURI: true
  URISchemes:
    - http
    - https
  Exclude:
    - '*_spec.rb'

如果可能,应该在何处/如何配置?

1 个答案:

答案 0 :(得分:2)

您可以使用!ruby/regexp声明基于正则表达式匹配文件:

Metrics/LineLength:
  Max: 80
  AllowHeredoc: true
  AllowURI: true
  URISchemes:
    - http
    - https
  Exclude:
    - !ruby/regexp /_spec\.rb$/

RuboCop最近添加了new manual,您可以阅读有关包含和排除文件here的内容。

相关问题