class RuboCop::Cop::Lint::DuplicateHashKey

hash = { food: ‘apple’, other_food: ‘orange’ }
# good
@example
hash = { food: ‘apple’, food: ‘orange’ }
# bad
@example
This cop mirrors a warning in Ruby 2.2.
Checks for duplicated keys in hash literals.

def on_hash(node)

def on_hash(node)
  keys = node.keys.select(&:recursive_basic_literal?)
  return unless duplicates?(keys)
  consecutive_duplicates(keys).each { |key| add_offense(key) }
end