Skip to main content

Chef/Style/NegatingOnlyIf

Cookstyle cops page

The Cookstyle cops department: Chef/Style

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
Include
    Array

    Thank you for your feedback!

    ×