Method: RuboCop::Cop::Primer::DeprecatedArguments#on_send

Defined in:
lib/rubocop/cop/primer/deprecated_arguments.rb

#on_send(node) ⇒ Object

[View source]

270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/rubocop/cop/primer/deprecated_arguments.rb', line 270

def on_send(node)
  return unless valid_node?(node)
  return unless node.arguments?

  # we are looking for hash arguments and they are always last
  kwargs = node.arguments.last

  return unless kwargs.type == :hash

  kwargs.pairs.each do |pair|
    # Skip if we're not dealing with a symbol key
    next if pair.key.type != :sym

    key, value = extract_kv_from(pair)
    next unless DEPRECATED.key?(key) && DEPRECATED[key].key?(value)

    add_offense(pair, message: INVALID_MESSAGE)
  end
end