Skip to main content

UseRequireRelative

All Cookstyle Cops


The department is: Chef/Modernize

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


Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledYesAll Versions

Instead of using require with a File.expand_path and FILE use the simpler require_relative method.

Examples

incorrect

require File.expand_path('../../libraries/helpers', __FILE__)

correct

require_relative '../libraries/helpers'

Configurable attributes

NameDefault valueConfigurable values
Version Added5.22.0String
Exclude
  • **/metadata.rb
  • **/attributes/*.rb
  • **/Berksfile
Array

Was this page helpful?









Search Results