https://kotlinlang.org logo
#compose
Title
# compose
z

zsperske

10/05/2023, 7:25 PM
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

Zach Klippenstein (he/him) [MOD]

10/05/2023, 7:50 PM
@Andrew Bailey should we update that lint message to include at least one example of an actual name?
2
z

zsperske

10/05/2023, 7:54 PM
I was going to suggest that, super minor change that would have saved me 5 minutes
a

ascii

10/05/2023, 8:31 PM
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

zsperske

10/05/2023, 8:32 PM
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

ascii

10/05/2023, 8:32 PM
Actually, there's already `@see`s for all:
z

zsperske

10/05/2023, 8:35 PM
HTML report doesn’t have it which is where I was looking
👀 1
c

curioustechizen

10/06/2023, 3:13 AM
I thought the IDE quick fix offers the correct replacement. Doesn't it?
z

zsperske

10/06/2023, 3:15 AM
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

ascii

10/06/2023, 4:49 AM
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

Andrew Bailey

10/06/2023, 9:23 AM
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 🙃
4 Views