import: read the groups slot without a nilable parse
The absent file and the file that will not parse answered alike, but
through one variable, and a ternary that can be nil left the reader
holding a nil for Steep. Two guards instead, so what JSON.parse hands
back is the only thing indexed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KrREeoPLXx1qsYYq7qkL8h
diff --git a/lib/pro_tacts/import/staged.rb b/lib/pro_tacts/import/staged.rb
index 205f3ce..80565b9 100644
--- a/lib/pro_tacts/import/staged.rb
+++ b/lib/pro_tacts/import/staged.rb
@@ -122,11 +122,13 @@ module ProTacts
# assumption JSON says so about.
#: (String id) -> [Hash[String, Array[String]], Hash[String, Array[String]]]
def self.groups(id)
- raw = read(id, GROUPS)
- parsed = raw.nil? ? nil : JSON.parse(raw)
# #lists makes an empty map of anything that is not one, so
# the gone import and the half a file are the same answer
# here rather than two spellings of it.
+ raw = read(id, GROUPS)
+ return [lists(nil), lists(nil)] if raw.nil?
+
+ parsed = JSON.parse(raw)
return [lists(nil), lists(nil)] unless parsed.is_a?(Hash)
[lists(parsed[CHOSEN]), lists(parsed[NAMED])]