UseCreateIfMissing
The department is: Chef/RedundantCode
The full name of the cop is: Chef/RedundantCode/UseCreateIfMissing
Enabled by default | Supports autocorrection | Target Chef Version |
---|---|---|
Enabled | Yes | All Versions |
Use the :create_if_missing action instead of not_if with a ::File.exist(FOO) check.
Examples
incorrect
cookbook_file '/logs/foo/error.log' do
source 'error.log'
owner 'root'
group 'root'
mode '0644'
not_if { ::File.exists?('/logs/foo/error.log') }
end
correct
cookbook_file '/logs/foo/error.log' do
source 'error.log'
owner 'root'
group 'root'
mode '0644'
action :create_if_missing
end
Configurable attributes
Name | Default value | Configurable values |
---|---|---|
Version Added | 6.2.0 | String | Exclude |
| Array |
Was this page helpful?