fix: resolve unreachable duplicate elif 'DO*' branch in result_string() (#6) #39

Merged
Claude merged 2 commits from ai/paper-dynasty-card-creation#6 into main 2026-03-23 03:51:34 +00:00
Collaborator

Closes #6

Summary

The second elif "DO*" in data_string in result_string() was dead code. Since the first branch always matched any string containing "DO*" (including "DO**"), the spaces -= 2 adjustment for the DO** variant was silently skipped, producing incorrect spacing in card formatting.

Root cause: Both branches had identical conditions ("DO*" in data_string). The second could never be reached.

Fix: Changed the second branch to check "DO**" and reordered so "DO**" is checked before "DO*" — since "DO*" in "DO**" is True, the more-specific check must come first.

Files changed

  • creation_helpers.py — 2-line swap in result_string() (lines 621-624)

Test results

No test suite. Change verified by reading back modified file — diff contains only the 4-line functional swap, no cosmetic changes.

Other observations

The format-on-save@agent-toolkit plugin reformats quote styles on every Edit tool save. Used a Python one-liner for the surgical change to keep the diff minimal and avoid cosmetic noise.

Closes #6 ## Summary The second `elif "DO*" in data_string` in `result_string()` was dead code. Since the first branch always matched any string containing `"DO*"` (including `"DO**"`), the `spaces -= 2` adjustment for the `DO**` variant was silently skipped, producing incorrect spacing in card formatting. **Root cause:** Both branches had identical conditions (`"DO*" in data_string`). The second could never be reached. **Fix:** Changed the second branch to check `"DO**"` and reordered so `"DO**"` is checked before `"DO*"` — since `"DO*" in "DO**"` is `True`, the more-specific check must come first. ## Files changed - `creation_helpers.py` — 2-line swap in `result_string()` (lines 621-624) ## Test results No test suite. Change verified by reading back modified file — diff contains only the 4-line functional swap, no cosmetic changes. ## Other observations The `format-on-save@agent-toolkit` plugin reformats quote styles on every Edit tool save. Used a Python one-liner for the surgical change to keep the diff minimal and avoid cosmetic noise.
Claude added 1 commit 2026-03-21 04:33:19 +00:00
The second `elif "DO*" in data_string` was dead code — the first always
matched, so `spaces -= 2` for the DO** variant was silently skipped.
Fix: check "DO**" first (spaces -= 2), then "DO*" (spaces -= 1).

Closes #6

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-03-21 04:45:48 +00:00
Claude reviewed 2026-03-21 04:46:49 +00:00
Claude left a comment
Author
Collaborator

Review: LGTM ✓

Fix is correct and minimal.

Bug Confirmed

Lines 621–624 in the current file have identical elif "DO*" in data_string conditions. The second branch (spaces -= 2) is unreachable dead code — Python's elif chain short-circuits, so any DO** string matches the first branch and gets spaces -= 1 instead.

Fix Analysis

The two-part correction is sound:

  1. Condition fix: Second branch changed from "DO*""DO**" — now tests the specific variant.
  2. Ordering fix: "DO**" check moved before "DO*" — required because "DO*" in "DO**" evaluates True, so the more-specific match must come first (mirrors the existing SI** pattern already in the same block).

The spacing values (-2 for DO**, -1 for DO*) are consistent with DO** being one character longer and thus needing one additional space trimmed for card column alignment.

Scope

Diff is exactly 4 lines, no cosmetic noise. No other logic touched.

No Concerns

  • Logic: correct
  • Ordering: matches the SI**/SI* precedent in spirit
  • Risk: low (display-only formatting, no data or API impact)
  • No test suite exists; manual read-back verification is appropriate given the project's current test posture

Ready to merge.

## Review: LGTM ✓ **Fix is correct and minimal.** ### Bug Confirmed Lines 621–624 in the current file have identical `elif "DO*" in data_string` conditions. The second branch (`spaces -= 2`) is unreachable dead code — Python's `elif` chain short-circuits, so any `DO**` string matches the first branch and gets `spaces -= 1` instead. ### Fix Analysis The two-part correction is sound: 1. **Condition fix**: Second branch changed from `"DO*"` → `"DO**"` — now tests the specific variant. 2. **Ordering fix**: `"DO**"` check moved before `"DO*"` — required because `"DO*" in "DO**"` evaluates `True`, so the more-specific match must come first (mirrors the existing `SI**` pattern already in the same block). The spacing values (`-2` for `DO**`, `-1` for `DO*`) are consistent with `DO**` being one character longer and thus needing one additional space trimmed for card column alignment. ### Scope Diff is exactly 4 lines, no cosmetic noise. No other logic touched. ### No Concerns - Logic: correct - Ordering: matches the `SI**`/`SI*` precedent in spirit - Risk: low (display-only formatting, no data or API impact) - No test suite exists; manual read-back verification is appropriate given the project's current test posture Ready to merge.
Claude added 1 commit 2026-03-23 03:50:45 +00:00
cal approved these changes 2026-03-23 03:51:29 +00:00
cal left a comment
Owner

Approved — safe bug fix per PO triage.

Approved — safe bug fix per PO triage.
Claude merged commit 2b955dd8f7 into main 2026-03-23 03:51:34 +00:00
Claude deleted branch ai/paper-dynasty-card-creation#6 2026-03-23 03:51:35 +00:00
Sign in to join this conversation.
No reviewers
cal
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-card-creation#39
No description provided.