Class: RuboCop::Cop::Chef::ChefDeprecations::UsesDeprecatedMixins

Inherits:
RuboCop::Cop
  • Object
show all
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:


# bad
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.".freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



65
66
67
68
69
# File 'lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb', line 65

def autocorrect(node)
  lambda do |corrector|
    corrector.remove(node.loc.expression)
  end
end

#on_send(node) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb', line 51

def on_send(node)
  deprecated_mixin?(node) do
    add_offense(node, location: :expression, message: MSG, severity: :refactor)
  end

  deprecated_dsl?(node) do
    add_offense(node, location: :expression, message: MSG, severity: :refactor)
  end

  dsl_mixin_require?(node) do
    add_offense(node, location: :expression, message: MSG, severity: :refactor)
  end
end