class RuboCop::Cop::Chef::Modernize::IncludingMixinShelloutInResources

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

@example

#### incorrect
require 'chef/mixin/shell_out'
include Chef::Mixin::ShellOut
require 'chef/mixin/powershell_out'
include Chef::Mixin::PowershellOut

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

check_for_offenses(node) click to toggle source
# File lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb, line 59
def check_for_offenses(node)
  containing_dir = File.basename(File.dirname(processed_source.path))

  # only add offenses when we're in a custom resource or HWRP, but not a plain old library
  if containing_dir == 'resources' || hwrp_classes?(processed_source.ast)
    add_offense(node, severity: :refactor) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end
end
on_send(node) click to toggle source
# File lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb, line 70
def on_send(node)
  require_shellout?(node) do
    check_for_offenses(node)
  end

  include_shellout?(node) do
    check_for_offenses(node)
  end
end