Skip to main content

LazyInResourceGuard

The department is: LazyInResourceGuard

The full name of the cop is: Chef/Correctness/LazyInResourceGuard

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll Versions

Using lazy {} within a resource guard (not_if/only_if) will cause failures and is unnecessary as resource guards are always lazily evaluated.

Examples

incorrect

template '/etc/foo' do
  mode '0644'
  source 'foo.erb'
  only_if { lazy { ::File.exist?('/etc/foo')} }
end

correct

template '/etc/foo' do
  mode '0644'
  source 'foo.erb'
  only_if { ::File.exist?('/etc/foo') }
end

Configurable attributes

NameDefault valueConfigurable values
Version Added6.18.0String
Include
    Array

    Thank you for your feedback!

    ×









    Search Results