fix: address ComposeUnstableCollections
lint
This commit is contained in:
parent
a00bd046b6
commit
26a7298978
15 changed files with 28 additions and 30 deletions
|
@ -71,6 +71,7 @@ dependencies {
|
||||||
implementation(libs.compose.ui.tooling)
|
implementation(libs.compose.ui.tooling)
|
||||||
implementation(libs.dagger.hilt.android)
|
implementation(libs.dagger.hilt.android)
|
||||||
|
|
||||||
|
implementation(libs.kotlinx.collections.immutable)
|
||||||
implementation(libs.kotlinx.coroutines.android)
|
implementation(libs.kotlinx.coroutines.android)
|
||||||
implementation(libs.kotlinx.coroutines.core)
|
implementation(libs.kotlinx.coroutines.core)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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
|
<issue
|
||||||
id="StopShip"
|
id="StopShip"
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
errorLine2=" ~~~~~~">
|
errorLine2=" ~~~~~~">
|
||||||
<location
|
<location
|
||||||
file="src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt"
|
file="src/main/java/app/passwordstore/util/viewmodel/PGPKeyListViewModel.kt"
|
||||||
line="35"
|
line="38"
|
||||||
column="19"/>
|
column="19"/>
|
||||||
</issue>
|
</issue>
|
||||||
|
|
||||||
|
@ -227,17 +227,6 @@
|
||||||
column="4"/>
|
column="4"/>
|
||||||
</issue>
|
</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
|
<issue
|
||||||
id="UnknownNullness"
|
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?)>?)>>)"
|
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?)>?)>>)"
|
||||||
|
|
|
@ -35,10 +35,13 @@ import app.passwordstore.R
|
||||||
import app.passwordstore.crypto.GpgIdentifier
|
import app.passwordstore.crypto.GpgIdentifier
|
||||||
import app.passwordstore.ui.compose.theme.APSThemePreview
|
import app.passwordstore.ui.compose.theme.APSThemePreview
|
||||||
import app.passwordstore.util.extensions.conditional
|
import app.passwordstore.util.extensions.conditional
|
||||||
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
|
import kotlinx.collections.immutable.toPersistentList
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun KeyList(
|
fun KeyList(
|
||||||
identifiers: List<GpgIdentifier>,
|
identifiers: ImmutableList<GpgIdentifier>,
|
||||||
onItemClick: (identifier: GpgIdentifier) -> Unit,
|
onItemClick: (identifier: GpgIdentifier) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onKeySelected: ((identifier: GpgIdentifier) -> Unit)? = null,
|
onKeySelected: ((identifier: GpgIdentifier) -> Unit)? = null,
|
||||||
|
@ -141,9 +144,10 @@ private fun KeyListPreview() {
|
||||||
KeyList(
|
KeyList(
|
||||||
identifiers =
|
identifiers =
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
GpgIdentifier.fromString("ultramicroscopicsilicovolcanoconiosis@example.com"),
|
GpgIdentifier.fromString("ultramicroscopicsilicovolcanoconiosis@example.com"),
|
||||||
GpgIdentifier.fromString("0xB950AE2813841585"),
|
GpgIdentifier.fromString("0xB950AE2813841585"),
|
||||||
),
|
)
|
||||||
|
.toPersistentList(),
|
||||||
onItemClick = {}
|
onItemClick = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -155,7 +159,7 @@ private fun KeyListPreview() {
|
||||||
fun EmptyKeyListPreview() {
|
fun EmptyKeyListPreview() {
|
||||||
APSThemePreview {
|
APSThemePreview {
|
||||||
Box(modifier = Modifier.background(MaterialTheme.colorScheme.background)) {
|
Box(modifier = Modifier.background(MaterialTheme.colorScheme.background)) {
|
||||||
KeyList(identifiers = emptyList(), onItemClick = {})
|
KeyList(identifiers = persistentListOf(), onItemClick = {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,14 @@ import com.github.michaelbull.result.Ok
|
||||||
import com.github.michaelbull.result.map
|
import com.github.michaelbull.result.map
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
|
import kotlinx.collections.immutable.toPersistentList
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class PGPKeyListViewModel @Inject constructor(private val keyManager: PGPKeyManager) : ViewModel() {
|
class PGPKeyListViewModel @Inject constructor(private val keyManager: PGPKeyManager) : ViewModel() {
|
||||||
var keys: List<GpgIdentifier> by mutableStateOf(emptyList())
|
var keys: ImmutableList<GpgIdentifier> by mutableStateOf(persistentListOf())
|
||||||
|
|
||||||
init {
|
init {
|
||||||
updateKeySet()
|
updateKeySet()
|
||||||
|
@ -31,7 +34,7 @@ class PGPKeyListViewModel @Inject constructor(private val keyManager: PGPKeyMana
|
||||||
keys.mapNotNull { key -> KeyUtils.tryGetEmail(key) }
|
keys.mapNotNull { key -> KeyUtils.tryGetEmail(key) }
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
is Ok -> keys = result.value
|
is Ok -> keys = result.value.toPersistentList()
|
||||||
is Err -> TODO()
|
is Err -> TODO()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
|
@ -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-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
|
||||||
dagger-hilt-core = { module = "com.google.dagger:hilt-core", 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" }
|
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-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-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
|
||||||
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
|
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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
|
<issue
|
||||||
id="TrulyRandom"
|
id="TrulyRandom"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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>
|
</issues>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue