class RuboCop::Cop::InternalAffairs::NodeFirstOrLastArgument


node.last_argument
node.first_argument
# good

node.arguments[-1]
node.arguments.last
node.arguments[0]
node.arguments.first
# bad
@example
suggests the use of ‘node.first_argument` or `node.last_argument` instead.
Checks for the use of `node.arguments.first` or `node.arguments.last` and

def on_send(node)

def on_send(node)
  arguments_first_or_last?(node.parent) do |end_or_index|
    range = range_between(node.loc.selector.begin_pos, node.parent.source_range.end_pos)
    correct = case end_or_index
              when :first, 0 then 'first_argument'
              when :last, -1 then 'last_argument'
              else raise "Unknown end_or_index: #{end_or_index}"
              end
    message = format(MSG, correct: correct, incorrect: range.source)
    add_offense(range, message: message) do |corrector|
      corrector.replace(range, correct)
    end
  end
end