class RuboCop::Cop::Chef::Ruby::Ruby27KeywordArgumentWarnings

Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings.

@example

# bad
shell_out!('hostnamectl status', { returns: [0, 1] })
shell_out('hostnamectl status', { returns: [0, 1] })

# good
shell_out!('hostnamectl status', returns: [0, 1])
shell_out('hostnamectl status', returns: [0, 1])

Constants

MSG

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/chef/ruby/ruby_27_keyword_argument_warnings.rb, line 44
def on_send(node)
  positional_shellout?(node) do |h|
    next unless h.braces?

    add_offense(h.loc.expression, message: MSG, severity: :refactor) do |corrector|
      corrector.replace(h.loc.expression, h.loc.expression.source[1..-2])
    end
  end
end