diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2023-06-15 14:02:05 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2023-06-15 14:21:49 +0530 |
commit | 26a7298978a42cd7b8b2987c60edd602124edc5c (patch) | |
tree | a69cb2ece76696838617eb2861766499a219de7f | |
parent | a00bd046b6794d97bbff47d81054450db0c447fb (diff) |
fix: address `ComposeUnstableCollections` lint
-rw-r--r-- | app/build.gradle.kts | 1 | ||||
-rw-r--r-- | app/lint-baseline.xml | 15 | ||||
-rw-r--r-- | app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt | 14 | ||||
-rw-r--r-- | app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt | 7 | ||||
-rw-r--r-- | autofill-parser/lint-baseline.xml | 2 | ||||
-rw-r--r-- | coroutine-utils/lint-baseline.xml | 2 | ||||
-rw-r--r-- | crypto-common/lint-baseline.xml | 2 | ||||
-rw-r--r-- | crypto-pgpainless/lint-baseline.xml | 2 | ||||
-rw-r--r-- | format-common/lint-baseline.xml | 2 | ||||
-rw-r--r-- | gradle/libs.versions.toml | 1 | ||||
-rw-r--r-- | passgen/diceware/lint-baseline.xml | 2 | ||||
-rw-r--r-- | passgen/random/lint-baseline.xml | 2 | ||||
-rw-r--r-- | sentry-stub/lint-baseline.xml | 2 | ||||
-rw-r--r-- | ssh/lint-baseline.xml | 2 | ||||
-rw-r--r-- | ui-compose/lint-baseline.xml | 2 |
15 files changed, 28 insertions, 30 deletions
diff --git a/app/build.gradle.kts b/app/build.gradle.kts index aacca7a5..5ba7b7a0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -71,6 +71,7 @@ dependencies { implementation(libs.compose.ui.tooling) implementation(libs.dagger.hilt.android) + implementation(libs.kotlinx.collections.immutable) implementation(libs.kotlinx.coroutines.android) implementation(libs.kotlinx.coroutines.core) diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml index de1f0a60..5ccbd208 100644 --- a/app/lint-baseline.xml +++ b/app/lint-baseline.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> <issue id="StopShip" @@ -8,7 +8,7 @@ errorLine2=" ~~~~~~"> <location file="src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt" - line="35" + line="38" column="19"/> </issue> @@ -228,17 +228,6 @@ </issue> <issue - id="ComposeUnstableCollections" - message="The Compose Compiler cannot infer the stability of a parameter if a List<GpgIdentifier> is used in it, even if the item type is stable.
You should use Kotlinx Immutable Collections instead: `identifiers: ImmutableList<GpgIdentifier>` or create an `@Immutable` wrapper for this class: `@Immutable data class IdentifiersList(val items: List<GpgIdentifier>)`
See https://slackhq.github.io/compose-lints/rules/#avoid-using-unstable-collections for more information." - errorLine1=" identifiers: List<GpgIdentifier>," - errorLine2=" ~~~~~~~~~~~~~~~~~~~"> - <location - file="src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt" - line="36" - column="16"/> - </issue> - - <issue id="UnknownNullness" message="Should explicitly declare type here since implicit type does not specify nullness (Lazy<Array<(GitCommand<out (Any or Any?)> or GitCommand<out (Any or Any?)>?)>>)" errorLine1=" override val commands by unsafeLazy {" diff --git a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt index f157cb12..04a57635 100644 --- a/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt +++ b/app/src/main/java/app/passwordstore/ui/pgp/PGPKeyList.kt @@ -35,10 +35,13 @@ import app.passwordstore.R import app.passwordstore.crypto.GpgIdentifier import app.passwordstore.ui.compose.theme.APSThemePreview import app.passwordstore.util.extensions.conditional +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.persistentListOf +import kotlinx.collections.immutable.toPersistentList @Composable fun KeyList( - identifiers: List<GpgIdentifier>, + identifiers: ImmutableList<GpgIdentifier>, onItemClick: (identifier: GpgIdentifier) -> Unit, modifier: Modifier = Modifier, onKeySelected: ((identifier: GpgIdentifier) -> Unit)? = null, @@ -141,9 +144,10 @@ private fun KeyListPreview() { KeyList( identifiers = listOfNotNull( - GpgIdentifier.fromString("ultramicroscopicsilicovolcanoconiosis@example.com"), - GpgIdentifier.fromString("0xB950AE2813841585"), - ), + GpgIdentifier.fromString("ultramicroscopicsilicovolcanoconiosis@example.com"), + GpgIdentifier.fromString("0xB950AE2813841585"), + ) + .toPersistentList(), onItemClick = {} ) } @@ -155,7 +159,7 @@ private fun KeyListPreview() { fun EmptyKeyListPreview() { APSThemePreview { Box(modifier = Modifier.background(MaterialTheme.colorScheme.background)) { - KeyList(identifiers = emptyList(), onItemClick = {}) + KeyList(identifiers = persistentListOf(), onItemClick = {}) } } } diff --git a/app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt b/app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt index a21a6962..a08b41fa 100644 --- a/app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt +++ b/app/src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt @@ -13,11 +13,14 @@ import com.github.michaelbull.result.Ok import com.github.michaelbull.result.map import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject +import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.persistentListOf +import kotlinx.collections.immutable.toPersistentList import kotlinx.coroutines.launch @HiltViewModel class PGPKeyListViewModel @Inject constructor(private val keyManager: PGPKeyManager) : ViewModel() { - var keys: List<GpgIdentifier> by mutableStateOf(emptyList()) + var keys: ImmutableList<GpgIdentifier> by mutableStateOf(persistentListOf()) init { updateKeySet() @@ -31,7 +34,7 @@ class PGPKeyListViewModel @Inject constructor(private val keyManager: PGPKeyMana keys.mapNotNull { key -> KeyUtils.tryGetEmail(key) } } ) { - is Ok -> keys = result.value + is Ok -> keys = result.value.toPersistentList() is Err -> TODO() } } diff --git a/autofill-parser/lint-baseline.xml b/autofill-parser/lint-baseline.xml index f1f07858..4e08108e 100644 --- a/autofill-parser/lint-baseline.xml +++ b/autofill-parser/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> diff --git a/coroutine-utils/lint-baseline.xml b/coroutine-utils/lint-baseline.xml index f1f07858..4e08108e 100644 --- a/coroutine-utils/lint-baseline.xml +++ b/coroutine-utils/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> diff --git a/crypto-common/lint-baseline.xml b/crypto-common/lint-baseline.xml index 21105025..4e08108e 100644 --- a/crypto-common/lint-baseline.xml +++ b/crypto-common/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="cli" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> diff --git a/crypto-pgpainless/lint-baseline.xml b/crypto-pgpainless/lint-baseline.xml index f1f07858..4e08108e 100644 --- a/crypto-pgpainless/lint-baseline.xml +++ b/crypto-pgpainless/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> diff --git a/format-common/lint-baseline.xml b/format-common/lint-baseline.xml index f1f07858..4e08108e 100644 --- a/format-common/lint-baseline.xml +++ b/format-common/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 34114e80..3ba314b8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -67,6 +67,7 @@ dagger-hilt-android = { module = "com.google.dagger:hilt-android", version.ref = dagger-hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" } dagger-hilt-core = { module = "com.google.dagger:hilt-core", version.ref = "hilt" } kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" } +kotlinx-collections-immutable = "org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.5" kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" } kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } diff --git a/passgen/diceware/lint-baseline.xml b/passgen/diceware/lint-baseline.xml index f1f07858..4e08108e 100644 --- a/passgen/diceware/lint-baseline.xml +++ b/passgen/diceware/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> diff --git a/passgen/random/lint-baseline.xml b/passgen/random/lint-baseline.xml index 4a3e95b7..8e8d016c 100644 --- a/passgen/random/lint-baseline.xml +++ b/passgen/random/lint-baseline.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> <issue id="TrulyRandom" diff --git a/sentry-stub/lint-baseline.xml b/sentry-stub/lint-baseline.xml index 21105025..4e08108e 100644 --- a/sentry-stub/lint-baseline.xml +++ b/sentry-stub/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="cli" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> diff --git a/ssh/lint-baseline.xml b/ssh/lint-baseline.xml index f1f07858..b7491439 100644 --- a/ssh/lint-baseline.xml +++ b/ssh/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="cli" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> diff --git a/ui-compose/lint-baseline.xml b/ui-compose/lint-baseline.xml index f1f07858..4e08108e 100644 --- a/ui-compose/lint-baseline.xml +++ b/ui-compose/lint-baseline.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<issues format="6" by="lint 8.2.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha06)" variant="all" version="8.2.0-alpha06"> +<issues format="6" by="lint 8.2.0-alpha08" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0-alpha08)" variant="all" version="8.2.0-alpha08"> </issues> |