slackhq / compose-lints

Lint checks to aid with a healthy adoption of Compose
https://slackhq.github.io/compose-lints
Apache License 2.0
387 stars 20 forks source link

Proposed rule: don't use `hashCode` in the item key for Lazy* Composables #374

Open yogurtearl opened 1 month ago

yogurtearl commented 1 month ago

Proposed rule: don't use hashCode in the item key for Lazy* Composables

Item key should be unique.

.hashCode() is not unique.

e.g. these all have the same hash code, even on JS, WASM, etc, same hashcode is unlikely, but not impossible in the wild.

println("aaaa".hashCode())
println("aabB".hashCode())
println("aac#".hashCode())
println("bBaa".hashCode())
println("bBbB".hashCode())
println("c#aa".hashCode())
println("c#bB".hashCode())
println("c#c#".hashCode())
ZacSweers commented 1 month ago

PR welcome!