Class: RuboCop::Cop::Chef::Modernize::DslIncludeInResource

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
RangeHelp
Defined in:
lib/rubocop/cop/chef/modernize/dsl_include_in_resource.rb

Overview

Chef Infra Client 12.4+ includes the Chef::DSL::Recipe in the resource and provider classed by default so there is no need to include this DSL in your resources or providers.

Examples:


### incorrect
include Chef::DSL::Recipe
include Chef::DSL::IncludeRecipe

Constant Summary collapse

MSG =
'Chef Infra Client 12.4+ includes the Chef::DSL::Recipe in the resource and provider classed by default so there is no need to include this DSL in your resources or providers.'
RESTRICT_ON_SEND =
[:include].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/rubocop/cop/chef/modernize/dsl_include_in_resource.rb', line 44

def on_send(node)
  dsl_include?(node) do
    add_offense(node, severity: :refactor) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end
end