Class: RuboCop::Cop::Chef::ChefModernize::IncludingMixinShelloutInResources

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

Overview

There is no need to include Chef::Mixin::ShellOut in resources or providers as this is already done by Chef Infra Client 12.4+.

Examples:


# bad
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut

Constant Summary collapse

MSG =
'There is no need to include Chef::Mixin::ShellOut in resources or providers as this is already done by Chef Infra Client 12.4+.'.freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



51
52
53
54
55
# File 'lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb', line 51

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

#on_send(node) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb', line 41

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

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