【发布时间】:2018-07-27 07:31:36
【问题描述】:
我们使用此设置在代码块之前需要空间
Layout/SpaceBeforeBlockBraces:
EnforcedStyle: space
但是,在 RSpec 示例中,当 expect 和 change 方法使用块以提高可读性时,我们不会在它们之后使用空格:
expect{ calling_the_method }.to change{ Model.all.size }.by(1)
Rubocop 抱怨上面的代码。 是否可以告诉它在特定方法之后忽略块或忽略匹配正则表达式的行?
我试过了:
Layout/SpaceBeforeBlockBraces:
EnforcedStyle: space
IgnoredPatterns: ['\A\s*((?:expect)|(.*change))']
【问题讨论】:
标签: rubocop