LazyInResourceGuard
The department is: LazyInResourceGuard
The full name of the cop is: Chef/Correctness/LazyInResourceGuard
Enabled by default | Supports autocorrection | Target Chef Version |
---|---|---|
Enabled | Yes | All 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
Name | Default value | Configurable values |
---|---|---|
Version Added | 6.18.0 | String |
Include | Array |