Skip to main content

NegatingOnlyIf

The department is: NegatingOnlyIf

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

Enabled by default Supports autocorrection Target Chef Version
Enabled Yes All 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

Name Default value Configurable values
Version Added 6.2.0 String
Include
Array

Was this page helpful?

×









Search Results