Skip to content

Fix 6 code review issues: subtitle robustness & lint cleanup#11

Merged
jpcottin merged 1 commit into
masterfrom
fix/code-review-issues
May 31, 2026
Merged

Fix 6 code review issues: subtitle robustness & lint cleanup#11
jpcottin merged 1 commit into
masterfrom
fix/code-review-issues

Conversation

@jpcottin

Copy link
Copy Markdown
Owner

Summary

Addresses 6 code review findings from PR #9 (subtitles) and #10 (sample torrents):

Critical Issues:

  • Fixed Compose anti-pattern: state mutation inside remember block → extracted subtitle detection logic to pure function
  • Fixed subtitle regex case-sensitivity: ([a-z]{2}) now matches uppercase codes like EN_US
  • Fixed empty display language fallback for unknown locale codes (e.g., xx → shows xx instead of blank)
  • Removed unused baseNameNoExt variable

Medium Issues:

  • Added snackbar confirmation when sample torrents are added
  • Converted deprecated SharedPreferences.edit() to KTX extension function

Code Quality:

  • Added 6 unit tests for subtitle detection edge cases (case-sensitivity, unknown locales, invalid files, empty dirs)
  • Fixed all lint warnings: removed redundant qualifiers, suppressed Java deprecation warnings appropriately
  • Converted legacy delay(3_000L) to delay(3.seconds) with Duration API
  • Converted redundant comparisons to Kotlin range syntax (in 0.01f..<0.05f)
  • Updated README.md with Recent Improvements section

Testing

  • ✅ All 24 unit tests pass
  • ✅ Lint clean with no errors or warnings
  • ✅ App builds and runs on R37 emulator
  • ✅ Torrents display correctly with full functionality
  • ✅ Subtitle detection and language selection works

Files Changed

  • PlayerScreen.kt — refactored subtitle logic, fixed state mutation, case-insensitive regex, KTX edit
  • MainScreen.kt — snackbar feedback, removed redundant qualifiers, KTX edit, range check
  • Theme.kt — fixed API 31 dynamic colors warning with @SuppressLint
  • DataRepository.kt — converted delay to Duration API
  • PlayerScreenTest.kt — new unit test suite for subtitle detection
  • README.md — added Recent Improvements section

…rnings

Critical fixes:
- Fixed state mutation in remember block (PlayerScreen.kt): extracted subtitle detection to testable function
- Fixed regex case-sensitivity: changed from ([a-z]{2}) to (?i)([a-zA-Z]{2}) to match uppercase language codes
- Fixed empty displayLanguage fallback: properly fall back to language code for unknown locales
- Removed unused baseNameNoExt variable

Medium fixes:
- Added snackbar confirmation when sample torrents are added (MainScreen.kt)
- Converted SharedPreferences.edit() to KTX extension for cleaner syntax

Code quality improvements:
- Created PlayerScreenTest with 6 unit tests for subtitle detection logic
- Fixed all lint warnings: removed redundant qualifiers, suppressed Java deprecation warnings
- Converted legacy Long delay to Duration (3.seconds)
- Converted redundant boolean comparisons to range check
- Updated README.md with Recent Improvements section

All 24 unit tests pass, lint clean, tested on R37 emulator.
@jpcottin jpcottin force-pushed the fix/code-review-issues branch from 5c0f664 to c953168 Compare May 31, 2026 04:23
@jpcottin jpcottin merged commit add197b into master May 31, 2026
4 checks passed
@jpcottin jpcottin deleted the fix/code-review-issues branch May 31, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant