Unused YAML keys
def find_keys(hash) | |
hash.flat_map do |key, value| | |
if value.is_a?(Hash) | |
find_keys(value) | |
else | |
key | |
end | |
end | |
end | |
phrases = YAML.load_file("lib/smart_answer_flows/locales/en/marriage-abroad.yml") | |
keys = find_keys(phrases).uniq | |
logic_file = File.open("lib/smart_answer_flows/marriage-abroad.rb", "r").read | |
test_file = File.open("test/integration/smart_answer_flows/marriage_abroad_test.rb", "r").read | |
unused = keys.select do |key| | |
logic_file.exclude?(key) && test_file.exclude?(key) | |
end - %w(description hint) | |
puts "Potentially unused keys (they may be coming from interpolated strings in the logic file):" | |
puts unused |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment