Skip to main content

NegatingOnlyIf

All Cookstyle Cops


The department is: Chef/Style

The full name of the cop is: Chef/Style/NegatingOnlyIf


Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll Versions

Instead of using only_if conditionals with ! to negate the returned value, use not_if which is easier to read

Examples

incorrect

package 'legacy-sysv-deps' do
  only_if { !systemd }
end

correct

package 'legacy-sysv-deps' do
  not_if { systemd }
end

Configurable attributes

NameDefault valueConfigurable values
Version Added6.2.0String
Exclude
  • **/metadata.rb
  • **/Berksfile
Array

Was this page helpful?









Search Results