Class: RuboCop::Cop::Chef::ChefDeprecations::UsesRunCommandHelper

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

Overview

Use ‘shell_out!’ instead of the legacy ‘run_command’ or ‘run_command_with_systems_locale’ helpers for shelling out. The run_command helper was removed in Chef Infra Client 13.

Examples:


# bad
require 'chef/mixin/command'
include Chef::Mixin::Command

run_command('/bin/foo')
run_command_with_systems_locale('/bin/foo')

# good
shell_out!('/bin/foo')

Constant Summary collapse

MSG =
"Use 'shell_out!' instead of the legacy 'run_command' or 'run_command_with_systems_locale' helpers for shelling out. The run_command helper was removed in Chef Infra Client 13.".freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rubocop/cop/chef/deprecation/run_command_helper.rb', line 44

def on_send(node)
  calls_run_command?(node) do
    add_offense(node, location: :expression, message: MSG, severity: :refactor) unless defines_run_command?(processed_source.ast)
  end

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

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