如果我写
if !File.exists('file_path')
# create file
end
我看到 RuboCop 警告:
Favour `unless` over `if` for negative conditions
不幸的是,在这种情况下使用
unless
有时会导致我的认知混乱。我不是唯一一个,请参阅此问题。
那么我应该在我的
.rubcopy.yml
文件中放入什么来关闭这个警察?
您必须将以下内容放入您的
.rubocop.yml
配置文件中:
Style/NegatedIf:
Enabled: false
要禁用以下 Rubocop 警告:
Favour `unless` over `if` for negative conditions