fix: codebase audit fixes — safety, accessibility, and production hygiene

Address 16 issues from external audit:
- Move StoreKit transaction listener ownership to StoreManager singleton with proper deinit
- Remove noisy VoiceOver announcements, add missing accessibility on StatPill and BootstrapLoadingView
- Replace String @retroactive Identifiable with IdentifiableShareCode wrapper
- Add crash guard in AchievementEngine getContributingVisitIds + cache stadium lookups
- Pre-compute GamesHistoryViewModel filtered properties to avoid redundant SwiftUI recomputation
- Remove force-unwraps in ProgressMapView with safe guard-let fallback
- Add diff-based update gating in ItineraryTableViewWrapper to prevent unnecessary reloads
- Replace deprecated UIScreen.main with UIWindowScene lookup
- Add deinit task cancellation in ScheduleViewModel and SuggestedTripsGenerator
- Wrap ~234 unguarded print() calls across 27 files in #if DEBUG

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-02-22 00:07:53 -06:00
parent 826eadbc0f
commit 91c5eac22d
32 changed files with 434 additions and 67 deletions

View File

@@ -117,17 +117,21 @@ final class ScenarioEPlanner: ScenarioPlanner {
}
}
#if DEBUG
print("🔍 ScenarioE Step 2: Found \(allHomeGames.count) total home games across \(selectedTeamIds.count) teams")
for (teamId, games) in homeGamesByTeam {
let teamName = request.teams[teamId]?.fullName ?? teamId
print("🔍 \(teamName): \(games.count) home games")
}
#endif
//
// Step 3: Generate sliding windows across the season
//
let windowDuration = request.preferences.teamFirstMaxDays
#if DEBUG
print("🔍 ScenarioE Step 3: Window duration = \(windowDuration) days")
#endif
let validWindows = generateValidWindows(
homeGamesByTeam: homeGamesByTeam,
@@ -150,13 +154,17 @@ final class ScenarioEPlanner: ScenarioPlanner {
)
}
#if DEBUG
print("🔍 ScenarioE Step 3: Found \(validWindows.count) valid windows")
#endif
// Sample windows if too many exist
let windowsToEvaluate: [DateInterval]
if validWindows.count > maxWindowsToEvaluate {
windowsToEvaluate = sampleWindows(validWindows, count: maxWindowsToEvaluate)
#if DEBUG
print("🔍 ScenarioE Step 3: Sampled down to \(windowsToEvaluate.count) windows")
#endif
} else {
windowsToEvaluate = validWindows
}
@@ -280,7 +288,9 @@ final class ScenarioEPlanner: ScenarioPlanner {
// Early exit if we have enough options
if allItineraryOptions.count >= maxResultsToReturn * 5 {
#if DEBUG
print("🔍 ScenarioE: Early exit at window \(windowIndex + 1) with \(allItineraryOptions.count) options")
#endif
break
}
}
@@ -331,7 +341,9 @@ final class ScenarioEPlanner: ScenarioPlanner {
)
}
#if DEBUG
print("🔍 ScenarioE: Returning \(rankedOptions.count) options")
#endif
return .success(rankedOptions)
}