Skip to content

M16 (refactor): extract utcDayString shared helper (deduplicate 4 sites) #69

Closed

Description

@wei18

Source: Code Reviewer audit Wave 3, finding #16 (2026-05-20)

Problem

utcDayString(from:) is duplicated identically in 4 places, each carrying its own // swiftlint:disable force_unwrapping for the TimeZone(identifier: "UTC")! lookup.

Affected files

  • Packages/SudokuKit/Sources/GameCenterClient/SubmitGuards.swift (~line 89)
  • Packages/SudokuKit/Sources/PuzzleStore/PuzzleStore.swift (search utcDayString)
  • Packages/SudokuKit/Sources/GameCenterClient/AchievementEvaluator.swift (~line 137)
  • Packages/SudokuKit/Sources/Persistence/Live/SavedGameStore.swift (~line 198)

Proposal

Extract to a single internal helper:

enum UTCDay {
    static func string(from date: Date) -> String { ... }
}

Place in the smallest shared leaf module that all 4 consumers can depend on (likely a tiny SudokuTime target, or co-locate with existing date helpers).

Trade-off: if cross-module dependency would be uglier than 4 lines of duplication, accept the duplication and consolidate the swiftlint suppression instead — but the audit recommended extraction.

Acceptance

  • 4 duplicated copies removed
  • 1 helper exists
  • All test suites that exercise day-bucket logic still pass

Out of scope

  • Not blocking v2 ship

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions