Class: RuboCop::Cop::Chef::Deprecations::UsesRunCommandHelper

Inherits:
Base
  • 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:


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

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

### correct
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."
RESTRICT_ON_SEND =
[:require, :run_command, :run_command_with_systems_locale, :include].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



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

def on_send(node)
  calls_run_command?(node) do
    add_offense(node, severity: :warning) unless defines_run_command?(processed_source.ast)
  end

  require_mixin_command?(node) do
    add_offense(node, severity: :warning)
  end

  include_mixin_command?(node) do
    add_offense(node, severity: :warning)
  end
end