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 defaultSupports autocorrectionTarget Chef Version
EnabledYesAll 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

NameDefault valueConfigurable values
Version Added6.11.0String
Exclude
  • **/metadata.rb
  • **/Berksfile
  • **/attributes/*.rb
Array

Was this page helpful?









Search Results