Class: RuboCop::Cop::Chef::Deprecations::UsesDeprecatedMixins

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

Overview

Don’t use deprecated Mixins no longer included in Chef Infra Client 14 and later.

Examples:


### incorrect
include Chef::Mixin::LanguageIncludeAttribute
include Chef::Mixin::RecipeDefinitionDSLCore
include Chef::Mixin::LanguageIncludeRecipe
include Chef::Mixin::Language
include Chef::DSL::Recipe::FullDSL
require 'chef/mixin/language'
require 'chef/mixin/language_include_attribute'
require 'chef/mixin/language_include_recipe'

Constant Summary collapse

MSG =
"Don't use deprecated Mixins no longer included in Chef Infra Client 14 and later."
RESTRICT_ON_SEND =
[:include, :require].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb', line 55

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

  deprecated_dsl?(node) do
    add_offense(node, severity: :warning) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end

  dsl_mixin_require?(node) do
    add_offense(node, severity: :warning) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end
end