我想在Rubocop中为全局匹配*_spec.rb
(Serverspec文件)的文件名禁用行长度检查。
我尝试按以下方式将Exclude
添加到config/default.yml
,但它不起作用(没有错误,检测到攻击):
Metrics/LineLength:
Max: 80
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- '*_spec.rb'
如果可能,应该在何处/如何配置?
答案 0 :(得分:2)
您可以使用!ruby/regexp
声明基于正则表达式匹配文件:
Metrics/LineLength:
Max: 80
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- !ruby/regexp /_spec\.rb$/
RuboCop最近添加了new manual,您可以阅读有关包含和排除文件here的内容。