Past scores - #8
Conversation
Code Review - PR #8: Past ScoresThank you for implementing the games won tracking feature! Below is my detailed review: Critical Issues1. Code Duplication (Lines 142-164)Severity: High There is significant code duplication in ContentView.swift. Lines 142-152 and lines 154-164 are exact duplicates containing dangerColor definition and player1InDanger/player2InDanger computed properties. Recommendation: Remove lines 154-164 entirely. This is likely a merge/paste error. Code Quality & Best Practices2. UserDefaults Access PatternSeverity: Medium The GameViewModel uses didSet property observers to persist data to UserDefaults. Issues include:
Recommendations:
3. Missing DocumentationSeverity: Low The new resetGamesWon() function (line 130) and games won properties lack documentation comments. Potential Bugs4. Games Won Increment TimingSeverity: Medium In checkForWinner() (lines 95-100), games won is incremented immediately when a player reaches the winning score. If the user resets the game without dismissing the winner modal, the counter has already been incremented. Scenario:
Recommendation: Consider moving the increment to occur only when the NEW GAME button is pressed. 5. No Validation for Games Won ValuesSeverity: Low The games won counter can theoretically become negative. Consider adding validation to ensure non-negative values. UI/UX Observations6. AccessibilitySeverity: Medium The games won text (lines 354-365) lacks accessibility labels. Consider adding .accessibilityLabel() and .accessibilityHint() modifiers to improve VoiceOver support. Test Coverage7. Missing TestsSeverity: Medium No test files were found in the repository. Consider adding unit tests for:
SummaryMust Fix:
Should Fix:
Nice to Have:
The feature implementation is solid and follows existing code patterns well. Main concern is the code duplication which should be removed before merging. Great work on this feature! |
No description provided.