Skip to content

Commit

Permalink
check for duplicates in validate_json workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Kefaku committed Oct 2, 2023
1 parent b83d7da commit ef8b667
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions script/validate_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module ExitCodes
UNEXPECTED_LANGUAGE_KEY = 10 # Unexpected language key for translation
UNSUPPORTED_FIELD = 11 # Unsupported field for site entry
UNEXPECTED_NOTES = 12 # Unexpected notes key for translation
DUPLICATES = 13 # Duplicate entries
end

SupportedDifficulties = ["easy", "medium", "hard", "limited", "impossible"]
Expand Down Expand Up @@ -143,6 +144,13 @@ def validate_site_translation(is_sites_json, keys_in_language_json, file)
json = JSON.parse(File.read(file))
is_sites_json = File.basename(file) =~ /sites.json/
keys_in_language_json = []

# check for duplicates
if json.uniq.length != json.length
STDERR.puts file + " contains duplicates"
exit ExitCodes::DUPLICATES
end

# check for alphabetical ordering
json.each_with_index do |(key, _), i|
# sites.json is an array of objects; this would expand to:
Expand Down

0 comments on commit ef8b667

Please sign in to comment.