Class: RuboCop::Cop::Chef::Deprecations::RequireRecipe

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/deprecation/require_recipe.rb

Overview

Make sure to use include_recipe instead of require_recipe

Examples:


### incorrect
require_recipe 'foo'

### correct
include_recipe 'foo'

Constant Summary collapse

MSG =
'Use include_recipe instead of the require_recipe method'
RESTRICT_ON_SEND =
[:require_recipe].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



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

def on_send(node)
  require_recipe?(node) do
    add_offense(node.loc.selector, severity: :warning) do |corrector|
      corrector.replace(node.loc.selector, 'include_recipe')
    end
  end
end