discourse/lib/i18n/duplicate_key_finder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
412 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require_relative "locale_file_walker"
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
2018-06-07 01:28:18 -04:00
def handle_scalar(node, depth, parents)
super
@keys_with_count[parents.join('.')] += 1
end
end