Method: RuboCop::Cop::Lint::DuplicateHashKey#on_hash

Defined in:
lib/rubocop/cop/lint/duplicate_hash_key.rb

#on_hash(node) ⇒ Object

[View source]

23
24
25
26
27
28
29
# File 'lib/rubocop/cop/lint/duplicate_hash_key.rb', line 23

def on_hash(node)
  keys = node.keys.select { |key| key.recursive_basic_literal? || key.const_type? }

  return unless duplicates?(keys)

  consecutive_duplicates(keys).each { |key| add_offense(key) }
end