compose-lints icon indicating copy to clipboard operation
compose-lints copied to clipboard

Idea: Add a lint that looks for un-remembered instantiation of types or functions whose names end in "State"

Open ZacSweers opened this issue 2 years ago • 3 comments

This would be similar to the new UnrememberedStateDetector in androidx, but be a warning lint to catch likely cases. @StateFactoryMarker works for functions, but it doesn't help with cases where people instantiate state classes directly.

Thoughts @chrisbanes @mrmans0n?

ZacSweers avatar Sep 25 '23 03:09 ZacSweers

Sounds good to me! I thought we had something like that already? Or maybe it was an idea we had but never got around to implementing.

chrisbanes avatar Sep 25 '23 07:09 chrisbanes

We have the view model factory lint but not sure there's anything else

ZacSweers avatar Sep 25 '23 19:09 ZacSweers

Note for the future - could just be a modified version of the first-party lint https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/runtime/runtime-lint/src/main/java/androidx/compose/runtime/lint/UnrememberedStateDetector.kt

ZacSweers avatar Sep 26 '23 02:09 ZacSweers