Skip to main content

NegatingOnlyIf

The department is: NegatingOnlyIf

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

    Thank you for your feedback!

    ×









    Search Results