Skip to main content

LazyInResourceGuard

All Cookstyle Cops


The department is: Chef/Correctness

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
Exclude
  • **/metadata.rb
  • **/Berksfile
Array

Was this page helpful?









Search Results