Rubocop:如何从指标中排除文件名模式?
Rubocop: how can I exclude a filename pattern from a metric?
我想在 Rubocop 中全局禁用与 *_spec.rb
(Serverspec 文件)匹配的文件名的行长度检查。
我尝试按以下方式将 Exclude
添加到 config/default.yml
,但没有成功(没有错误,检测到违规行为):
Metrics/LineLength:
Max: 80
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- '*_spec.rb'
如果可以,where/how应该这样配置吗?
您可以使用 !ruby/regexp
声明基于正则表达式匹配文件:
Metrics/LineLength:
Max: 80
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- !ruby/regexp /_spec\.rb$/
RuboCop 最近添加了一个 new manual, and you can read about including and excluding files here。
我想在 Rubocop 中全局禁用与 *_spec.rb
(Serverspec 文件)匹配的文件名的行长度检查。
我尝试按以下方式将 Exclude
添加到 config/default.yml
,但没有成功(没有错误,检测到违规行为):
Metrics/LineLength:
Max: 80
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- '*_spec.rb'
如果可以,where/how应该这样配置吗?
您可以使用 !ruby/regexp
声明基于正则表达式匹配文件:
Metrics/LineLength:
Max: 80
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- !ruby/regexp /_spec\.rb$/
RuboCop 最近添加了一个 new manual, and you can read about including and excluding files here。