Skip to main content

Chef/Correctness/LazyInResourceGuard

Cookstyle cops page

The Cookstyle cops department: Chef/Correctness

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