From de79cf03420c143e767946e7115a62194f32e006 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 27 May 2026 11:22:53 -0400 Subject: [PATCH] fix(android): detekt + silence JDK 22+ native-access warning Three issues: * AdminRequestsScreen line 105 MagicNumber on UUID prefix length 8. Extracted to USER_ID_PREFIX_LEN with rationale. * LibraryRepository TooManyFunctions (12/11) after shuffleLibrary addition. Same pattern as PlayerController / AuthStore: @Suppress at the class with rationale (function count scales with entity- family count, splitting would scatter plumbing). * JDK 22+ "restricted method java.lang.System::load" warning from Gradle's bundled native-platform jar. Add --enable-native-access=ALL-UNNAMED to org.gradle.jvmargs so the daemon opts the native loader in. Future-compat: Gradle will declare this in the jar's manifest eventually and the flag becomes redundant. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../fabledsword/minstrel/admin/ui/AdminRequestsScreen.kt | 6 +++++- .../minstrel/library/data/LibraryRepository.kt | 5 +++++ android/gradle.properties | 8 +++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/com/fabledsword/minstrel/admin/ui/AdminRequestsScreen.kt b/android/app/src/main/java/com/fabledsword/minstrel/admin/ui/AdminRequestsScreen.kt index 39fa8942..4156564a 100644 --- a/android/app/src/main/java/com/fabledsword/minstrel/admin/ui/AdminRequestsScreen.kt +++ b/android/app/src/main/java/com/fabledsword/minstrel/admin/ui/AdminRequestsScreen.kt @@ -102,7 +102,7 @@ private fun RequestList( AdminRequestRow( req = req, requester = usernames[req.userId] - ?: req.userId.takeIf { it.isNotEmpty() }?.take(8) + ?: req.userId.takeIf { it.isNotEmpty() }?.take(USER_ID_PREFIX_LEN) ?: "unknown", onApprove = { onApprove(req.id) }, onReject = { onReject(req.id) }, @@ -176,3 +176,7 @@ private fun LoadingCentered() { CircularProgressIndicator(color = MaterialTheme.colorScheme.primary) } } + +// UUID prefix length used as a friendlier-than-raw-UUID fallback when +// the admin users list fetch fails and we can't resolve userId → name. +private const val USER_ID_PREFIX_LEN = 8 diff --git a/android/app/src/main/java/com/fabledsword/minstrel/library/data/LibraryRepository.kt b/android/app/src/main/java/com/fabledsword/minstrel/library/data/LibraryRepository.kt index 0164e1d2..f25d779c 100644 --- a/android/app/src/main/java/com/fabledsword/minstrel/library/data/LibraryRepository.kt +++ b/android/app/src/main/java/com/fabledsword/minstrel/library/data/LibraryRepository.kt @@ -27,6 +27,11 @@ import javax.inject.Singleton * NetworkModule, we don't @Provides per-endpoint Retrofit interfaces * — fewer Hilt bindings, locality of reference. */ +// LibraryRepository owns reads + refreshes for three entity families +// (artists / albums / tracks) plus shuffle. Function count scales with +// entity-family count; splitting into per-family repos would +// scatter the shared dao + retrofit plumbing for no real gain. +@Suppress("TooManyFunctions") @Singleton class LibraryRepository @Inject constructor( private val artistDao: CachedArtistDao, diff --git a/android/gradle.properties b/android/gradle.properties index 6657f33c..d0549dd1 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,10 @@ -org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 +# --enable-native-access=ALL-UNNAMED silences the JDK 22+ "restricted +# method in java.lang.System has been called" warning that Gradle 9.1's +# bundled native-platform-0.22-milestone-28.jar trips via System.load(). +# Future JDKs will require this opt-in to allow native loads from +# unnamed modules; the jar itself doesn't yet declare native access in +# its manifest, so we opt in at the daemon level. +org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 --enable-native-access=ALL-UNNAMED org.gradle.parallel=true org.gradle.caching=true org.gradle.configuration-cache=true