如何关闭RuboCop中偏好unless替代if处理负条件的规则?
关闭RuboCop的"Favour
unless over if for negative conditions"规则 要禁用这条规则,在你的.rubocop.yml文件中添加以下配置即可:
Style/UnlessElse: Enabled: false
如果只是想临时在某段代码里跳过该检查,也可以用代码注释实现:
# rubocop:disable Style/UnlessElse if !File.exists('file_path') # create file end # rubocop:enable Style/UnlessElse
内容的提问来源于stack exchange,提问作者Obromios
相关产品推荐
相关产品推荐

