Skip to main content

ConditionalUsingTest

All Cookstyle Cops


The department is: Chef/Modernize

The full name of the cop is: Chef/Modernize/ConditionalUsingTest


Enabled by default Supports autocorrection Target Chef Version
Enabled Yes All Versions

Use ::File.exist?('/foo/bar') instead of the slower ‘test -f /foo/bar’ which requires shelling out

Examples

incorrect

only_if 'test -f /bin/foo'

correct

only_if { ::File.exist?('bin/foo') }

Configurable attributes

Name Default value Configurable values
Version Added 6.11.0 String
Exclude
  • **/metadata.rb
  • **/Berksfile
  • **/attributes/*.rb
Array

Was this page helpful?

×









Search Results