Skip to content
New issue

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

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

Already on GitHub? # to your account

multiline-if-else: False negatives for android code style #828

Closed
BraisGabin opened this issue Aug 12, 2020 · 0 comments · Fixed by #1565
Closed

multiline-if-else: False negatives for android code style #828

BraisGabin opened this issue Aug 12, 2020 · 0 comments · Fixed by #1565
Labels
Milestone

Comments

@BraisGabin
Copy link

Expected Behavior

Extracted from Android Kotlin style guide

Braces are not required for when branches and if statement bodies which have no else if/else branches and which fit on a single line.
Braces are otherwise required for any if, for, when branch, do, and while statements, even when the body is empty or contains only a single statement.

I can't stand the same for Kotlin coding conventions (but I think that it should apply too). More about this in #812

Observed Behavior

This code is not flagged and it should:

if (true) 50
  .toString()
if (true) 50
else 55

I fixed this issues in a similar rule in detekt detekt/detekt#2835 and detekt/detekt#2051

Your Environment

  • Version of ktlint used: 0.37.2
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants