-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
Add a rule to flag places where ifBlank
and ifEmpty
can be used
#2840
Comments
This would go into the |
If no one is working on this, would like to take a stab at it. :) |
Thanks @MehWhatever for the help! We really appreciate your help. |
Do we also want to handle things like,
Though by opening that door, it would also make sense to catch these,
Which seems to be slightly tricky to catch. On another note do we have a style rule for this,
to |
I think it's better to start simple and improve in subsequent PRs. |
I think that this case can be generalized and create a new rule for it. I think that the desired code here should be:
I mean. a rule that detects an if that ends with a return and followed by that a return that could be changed by an
This should be handled by |
@MehWhatever I'm unassigning you from this issue. If you are still interested in this issue you can open the PR anyway :) |
Kotlin provides the functions
ifBlank
andifEmpty
so we should flag the points where this functions could be used. Example:if (api.name.isBlank()) "John" else api.name
can be replaced to:
api.name.ifBlank { "John" }
The same for
ifEmpty
.Context
https://twitter.com/kotlin/status/1277897234043097090
The text was updated successfully, but these errors were encountered: