There’s a compose lint warning for using `mutableS...
# compose
z
There’s a compose lint warning for using
mutableStateOf
with primitives like Int, Long, etc and it recommends “Instead, prefer to use a specialized primitive state implementation for
Int
,
Long
,
Float
, and
Double
when the state does not need to track null values and does not override the default
SnapshotMutationPolicy
.” Does anyone know what those specialized implementations are called? I found some
asIntState
methods in the Compose source but those appear to be read only Solved:
mutableDoubleStateOf
etc
z
@Andrew Bailey should we update that lint message to include at least one example of an actual name?
2
z
I was going to suggest that, super minor change that would have saved me 5 minutes
a
Would be a nice little improvement, just need to add
@see
with all of them. Just one could also be confusing. But doesn't lint already suggest the correct change? See screenshot.
z
Good point! I was reading a lint HTML report and not looking at the code. I just enable this as an error instead of warning
a
Actually, there's already `@see`s for all:
z
HTML report doesn’t have it which is where I was looking
👀 1
c
I thought the IDE quick fix offers the correct replacement. Doesn't it?
z
yeah it does, I was just taking an atypical route. I upgraded some warnings to errors and then ran lint on the whole project and looked at the HTML results instead of in the IDE. for other developers who follow after me, they will likely run into the error in the IDE and have the quickfix
👍 1
a
Side question: I wonder who's the target audience for HTML reports? To a developer, this report seems far less useful than IDE's Code -> Inspect. Of course it's not integrated with the IDE, but more than that it doesn't even offer the correct solution/workaround. Not sure if this is applies to all lint issues generally, or just this one. I guess you can share the exported file with others, but who exactly? I'd like to learn which role in the team benefits from HTML reports overall.
a
The lint message that appears in the IDE should also include the correct property to use, in addition to the quickfix. We can definitely edit the rule's main description that you're seeing in the HTML report, though, especially since I'm definitely seeing some readability and grammar issues now that I look at it again 🙃