Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yogurtearl opened this issue Apr 12, 2024 · 3 comments

Comments

@yogurtearl
Copy link

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()"

@ZacSweers
Copy link
Collaborator

Hmm, would a simple example of that be something like

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

?

@yogurtearl
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants