class RuboCop::Cop::Chef::Deprecations::ChefShellout

Don’t use the deprecated ‘Chef::ShellOut` class which was removed in Chef Infra Client 13. Use the `Mixlib::ShellOut` class instead, which behaves identically or convert to the simpler `shell_out` helper.

@example

#### incorrect
include Chef::ShellOut
require 'chef/shellout'
Chef::ShellOut.new('some_command')

#### correct
include Mixlib::ShellOut
require 'mixlib/shellout'
Mixlib::ShellOut.new('some_command')

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/chef/deprecation/chef_shellout.rb, line 60
def on_send(node)
  include_shellout?(node) do
    add_offense(node, severity: :warning) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end

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

  shellout_new?(node) do
    add_offense(node, severity: :warning) do |corrector|
      corrector.replace(node, node.source.gsub('Chef::ShellOut', 'Mixlib::ShellOut'))
    end
  end
end