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

Idea: Add a check for functions that don't need to be annotated with `@Composable` but are.

Open yogurtearl opened this issue 1 year ago • 3 comments

Some functions don't need to be @Composable but are.

Maybe the function originally used some other @Composable thing but it was removed at some point, would be nice to have a lint check that reported "@Composable can be removed from function foo()"

yogurtearl avatar Apr 12 '24 19:04 yogurtearl

Hmm, would a simple example of that be something like

@Composable fun example() = println("derp")

?

ZacSweers avatar Apr 12 '24 21:04 ZacSweers

Yes. :)

That would trigger the issue to say "@Composable is not needed for this function/property"

Ideally any function/property that compiles just fine and works the same if you remove the @Composable annotation should trigger the warning, but even just covering basic cases would still be useful as some cases might be harder to detect.

yogurtearl avatar Apr 12 '24 21:04 yogurtearl

This scenario can be hard to visually detect in code review for non-trivial functions, especially if you are not in an IDE.

yogurtearl avatar Apr 12 '24 21:04 yogurtearl