discourse/lib/i18n/duplicate_key_finder.rb
Loïc Guitaut 008b700a3f DEV: Upgrade to Rails 7
This patch upgrades Rails to version 7.0.2.4.
2022-04-28 11:51:03 +02:00

20 lines
403 B
Ruby

# frozen_string_literal: true
require "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
def handle_scalar(node, depth, parents)
super
@keys_with_count[parents.join('.')] += 1
end
end