Class: RuboCop::Cop::Chef::ChefDeprecations::RequireRecipe

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/chef/deprecation/require_recipe.rb

Overview

Make sure to use include_recipe instead of require_recipe

Examples:


# bad
require_recipe 'foo'

# good
include_recipe 'foo'

Constant Summary collapse

MSG =
'Use include_recipe instead of the require_recipe method'.freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



43
44
45
46
47
# File 'lib/rubocop/cop/chef/deprecation/require_recipe.rb', line 43

def autocorrect(node)
  lambda do |corrector|
    corrector.replace(node.loc.selector, 'include_recipe')
  end
end

#on_send(node) ⇒ Object



39
40
41
# File 'lib/rubocop/cop/chef/deprecation/require_recipe.rb', line 39

def on_send(node)
  require_recipe?(node) { add_offense(node, location: :selector, message: MSG, severity: :refactor) }
end