class RuboCop::Cop::Chef::Modernize::UseRequireRelative
Instead of using require with a File.expand_path and __FILE__ use the simpler require_relative method.
@example
### incorrect require File.expand_path('../../libraries/helpers', __FILE__) ### correct require_relative '../libraries/helpers'
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
Source
# File lib/rubocop/cop/chef/modernize/use_require_relative.rb, line 46 def on_send(node) require_with_expand_path?(node) do |file, path| return unless path.source == '__FILE__' add_offense(node, severity: :refactor) do |corrector| corrected_value = file.value corrected_value.slice!(%r{^../}) # take the first ../ off the path corrector.replace(node, "require_relative '#{corrected_value}'") end end end