library: fix all lint findings
- Commit
03b4e1ddbf88f12e26dea8a5006c17c8fa52a9a7- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 04:34 UTC (19 days ago)
- Parents
5168cca
Baseline (origin/main): 2 warnings, 5 hints in library source. ComposableNaming: NavBackStack.openSettingsIfRequested renamed to OpenSettingsIfRequested (Compose Unit-returning composables start uppercase); doc example and library test call sites updated. App call sites on other branches must rename on rebase. ObsoleteSdkInt: packageVersionCode dropped the pre-API-28 versionCode fallback; minSdk is 31 so longVersionCode is always available, and the now-unused Build import was removed. Remaining hints are MissingTranslation only (Weblate-managed translation backlog, not code-fixable). Verification: :library:lint -- 0 errors, 0 warnings in library source (5 MissingTranslation hints remain); :library:testDebugUnitTest -- green.
Diff
library/src/main/java/com/vayunmathur/library/util/AppPreferencesEntry.kt
diff --git a/library/src/main/java/com/vayunmathur/library/util/AppPreferencesEntry.kt b/library/src/main/java/com/vayunmathur/library/util/AppPreferencesEntry.ktindex d34813baad..85d493bbb5 100644--- a/library/src/main/java/com/vayunmathur/library/util/AppPreferencesEntry.kt+++ b/library/src/main/java/com/vayunmathur/library/util/AppPreferencesEntry.kt@@ -16,14 +16,14 @@ import androidx.compose.runtime.LaunchedEffect * * Call once from the composable that owns the back stack: *- * backStack.openSettingsIfRequested(Route.Settings)+ * backStack.OpenSettingsIfRequested(Route.Settings) * * Deliberately a push rather than a stack reset, so back returns to the app's * home screen rather than closing it - the user arrived from outside and has * nowhere else to go back to. */ @Composable-fun <T : NavKey> NavBackStack<T>.openSettingsIfRequested(settings: T) {+fun <T : NavKey> NavBackStack<T>.OpenSettingsIfRequested(settings: T) { val activity = LocalActivity.current LaunchedEffect(activity) { val launchedFromAppInfo =
library/src/main/java/com/vayunmathur/library/util/GameHubCompose.kt
diff --git a/library/src/main/java/com/vayunmathur/library/util/GameHubCompose.kt b/library/src/main/java/com/vayunmathur/library/util/GameHubCompose.ktindex baf522e615..01edfd6b74 100644--- a/library/src/main/java/com/vayunmathur/library/util/GameHubCompose.kt+++ b/library/src/main/java/com/vayunmathur/library/util/GameHubCompose.kt@@ -2,7 +2,6 @@ package com.vayunmathur.library.util import android.content.Context import android.content.pm.PackageManager-import android.os.Build import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect@@ -63,12 +62,8 @@ private fun packageVersionName(context: Context): String? { private fun packageVersionCode(context: Context): Long? { return try {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {- context.packageManager.getPackageInfo(context.packageName, 0).longVersionCode- } else {- @Suppress("DEPRECATION")- context.packageManager.getPackageInfo(context.packageName, 0).versionCode.toLong()- }+ // minSdk is 31, so longVersionCode (API 28+) is always available.+ context.packageManager.getPackageInfo(context.packageName, 0).longVersionCode } catch (_: PackageManager.NameNotFoundException) { null }
library/src/test/java/com/vayunmathur/library/util/LibraryNavResultsTest.kt
diff --git a/library/src/test/java/com/vayunmathur/library/util/LibraryNavResultsTest.kt b/library/src/test/java/com/vayunmathur/library/util/LibraryNavResultsTest.ktindex 9c3435866b..8e8c50f632 100644--- a/library/src/test/java/com/vayunmathur/library/util/LibraryNavResultsTest.kt+++ b/library/src/test/java/com/vayunmathur/library/util/LibraryNavResultsTest.kt@@ -20,7 +20,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -/** NavResultRegistry/ResultEffect delivery and openSettingsIfRequested. */+/** NavResultRegistry/ResultEffect delivery and OpenSettingsIfRequested. */ @RunWith(RobolectricTestRunner::class) class LibraryNavResultsTest { @@ -62,13 +62,13 @@ class LibraryNavResultsTest { Intent(action), ).create().get() - @Test fun openSettingsIfRequestedPushesSettingsAndConsumesIntent() {+ @Test fun OpenSettingsIfRequestedPushesSettingsAndConsumesIntent() { val stack = NavBackStack(arrayOf(Page("home"))) val activity = activityWithAction(Intent.ACTION_APPLICATION_PREFERENCES) rule.setContent { MaterialTheme { CompositionLocalProvider(LocalActivity provides activity) {- with(stack) { openSettingsIfRequested(Page("settings")) }+ with(stack) { OpenSettingsIfRequested(Page("settings")) } Text("Current ${stack.last().route}") } }@@ -79,13 +79,13 @@ class LibraryNavResultsTest { rule.onNodeWithText("Current settings").assertIsDisplayed() } - @Test fun openSettingsIfRequestedIgnoresNormalLaunch() {+ @Test fun OpenSettingsIfRequestedIgnoresNormalLaunch() { val stack = NavBackStack(arrayOf(Page("home"))) val activity = activityWithAction(Intent.ACTION_MAIN) rule.setContent { MaterialTheme { CompositionLocalProvider(LocalActivity provides activity) {- with(stack) { openSettingsIfRequested(Page("settings")) }+ with(stack) { OpenSettingsIfRequested(Page("settings")) } Text("Current ${stack.last().route}") } }@@ -95,13 +95,13 @@ class LibraryNavResultsTest { assertTrue(stack.backStack.size == 1) } - @Test fun openSettingsIfRequestedAlreadyOnSettingsDoesNotDuplicate() {+ @Test fun OpenSettingsIfRequestedAlreadyOnSettingsDoesNotDuplicate() { val stack = NavBackStack(arrayOf(Page("settings"))) val activity = activityWithAction(Intent.ACTION_APPLICATION_PREFERENCES) rule.setContent { MaterialTheme { CompositionLocalProvider(LocalActivity provides activity) {- with(stack) { openSettingsIfRequested(Page("settings")) }+ with(stack) { OpenSettingsIfRequested(Page("settings")) } Text("Current ${stack.last().route}") } }
library/src/test/java/com/vayunmathur/library/util/LibraryWave2NavTest.kt
diff --git a/library/src/test/java/com/vayunmathur/library/util/LibraryWave2NavTest.kt b/library/src/test/java/com/vayunmathur/library/util/LibraryWave2NavTest.ktindex 4e2db09378..ef4cec41c0 100644--- a/library/src/test/java/com/vayunmathur/library/util/LibraryWave2NavTest.kt+++ b/library/src/test/java/com/vayunmathur/library/util/LibraryWave2NavTest.kt@@ -185,13 +185,13 @@ class LibraryWave2NavTest { rule.waitForIdle() } - @Test fun openSettingsIfRequestedNoOpForNormalLaunch() {- // openSettingsIfRequested with a non-app-info intent is a no-op.+ @Test fun OpenSettingsIfRequestedNoOpForNormalLaunch() {+ // OpenSettingsIfRequested with a non-app-info intent is a no-op. val stack = NavBackStack(arrayOf(Screen("home2"))) rule.setContent { MaterialTheme { Column {- with(stack) { openSettingsIfRequested(Screen("settings")) }+ with(stack) { OpenSettingsIfRequested(Screen("settings")) } Text("SettingsHost") } }