-
Notifications
You must be signed in to change notification settings - Fork 506
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 multiline-loop to complement multiline-if-else #2298
Conversation
Tnx for your contribution. I will have a look after |
Hi Paul. I understand, thanks for your response. And also for pointing out the bracing difference between Kotlin and Android style guides. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done! I see that you picked up quite some conventions of the project. Please address the remarks.
...et-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRule.kt
Outdated
Show resolved
Hide resolved
...et-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRule.kt
Outdated
Show resolved
Hide resolved
...et-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRule.kt
Outdated
Show resolved
Hide resolved
...tandard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRuleTest.kt
Outdated
Show resolved
Hide resolved
...tandard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRuleTest.kt
Outdated
Show resolved
Hide resolved
...tandard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRuleTest.kt
Outdated
Show resolved
Hide resolved
...et-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRule.kt
Outdated
Show resolved
Hide resolved
for (i in 1..10) return 0 | ||
while (true) return 0 | ||
do return 0 while (true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Android style guide:
Braces are otherwise required for any if, for, when branch, do, and while statements and expressions, even when the body is empty or contains only a single statement.
Kotlin style guide does not mention it explicitly, but I am fine with imposing this on code styles.
Description
Related to #2223.
Added
MultiLineLoopRule
that, likeMultiLineIfElseRule
, checks violation infor
,while
, anddo
statements.Checklist
Before submitting the PR, please check following (checks which are not relevant may be ignored):
Closes #<xxx>
orFixes #<xxx>
(replace<xxx>
with issue number)CHANGELOG.md
is updatedDocumentation is updated. See difference between snapshot and release documentation