From 0e6f034e99038fc1145bdaf74b799d8853dcdbd1 Mon Sep 17 00:00:00 2001 From: Alex Lockwood Date: Fri, 31 Jan 2025 17:09:30 -0800 Subject: [PATCH] Update MutableStateParameter to also catch Mutable(Int,Float,Double,Long)State I didn't have time to test this (sorry) but I wanted to make this quick PR anyways since it seemed the easiest way to flag this issue. Feel free to push any updates and merge if you agree that we should also be catching these relatively new mutable state classes as well. (Disclaimer: I'm not a regex expert... which is why I prefixed this description with the fact that I didn't test this haha) --- .../kotlin/io/nlopez/compose/rules/MutableStateParameter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/common/src/main/kotlin/io/nlopez/compose/rules/MutableStateParameter.kt b/rules/common/src/main/kotlin/io/nlopez/compose/rules/MutableStateParameter.kt index b06f3405..ad8cb3a1 100644 --- a/rules/common/src/main/kotlin/io/nlopez/compose/rules/MutableStateParameter.kt +++ b/rules/common/src/main/kotlin/io/nlopez/compose/rules/MutableStateParameter.kt @@ -17,7 +17,7 @@ class MutableStateParameter : ComposeKtVisitor { } companion object { - private val MutableStateRegex = "MutableState<.*>\\??".toRegex() + private val MutableStateRegex = "(MutableState<.*>|Mutable(Int|Float|Double|Long)State)\\??".toRegex() val MutableStateParameterInCompose = """ MutableState shouldn't be used as a parameter in a @Composable function, as it promotes joint ownership over a state between a component and its user.