class RuboCop::Cop::InternalAffairs::RedundantMessageArgument

Checks for redundant message arguments to ‘#add_offense`. This method will automatically use `#message` or `MSG` (in that order of priority) if they are defined.

@example

# bad
add_offense(node, message: MSG)

# good
add_offense(node)

Constants

MSG
RESTRICT_ON_SEND

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/cop/internal_affairs/redundant_message_argument.rb, line 37
def on_send(node)
  return unless (kwargs = node_type_check(node))

  kwargs.pairs.each do |pair|
    redundant_message_argument(pair) do
      add_offense(pair) do |corrector|
        range = offending_range(pair)

        corrector.remove(range)
      end
    end
  end
end

Private Instance Methods

offending_range(node) click to toggle source
# File lib/rubocop/cop/internal_affairs/redundant_message_argument.rb, line 53
def offending_range(node)
  with_space = range_with_surrounding_space(node.source_range)

  range_with_surrounding_comma(with_space, :left)
end