2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-03-21 10:28:52 -04:00
|
|
|
require "locale_file_walker"
|
2017-02-24 05:35:33 -05:00
|
|
|
|
|
|
|
class DuplicateKeyFinder < LocaleFileWalker
|
|
|
|
|
|
|
|
def find_duplicates(path)
|
|
|
|
@keys_with_count = Hash.new { 0 }
|
|
|
|
handle_document(Psych.parse_file(path))
|
|
|
|
@keys_with_count.select { |key, count| count > 1 }.keys
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def handle_scalar(node, depth, parents)
|
|
|
|
super
|
|
|
|
@keys_with_count[parents.join('.')] += 1
|
|
|
|
end
|
|
|
|
end
|