Skip to content

Add multiline-loop to complement multiline-if-else - #2298

Merged
paul-dingemans merged 4 commits into
ktlint:masterfrom
hanggrian:master
Nov 16, 2023
Merged

paul-dingemans merged 4 commits into
ktlint:masterfrom
hanggrian:master

Conversation

@hanggrian

@hanggrian hanggrian commented Oct 9, 2023 •

Copy link
Copy Markdown
Contributor

Description

Related to #2223.

Added MultiLineLoopRule that, like MultiLineIfElseRule, checks violation in for, while, and do statements.

Checklist

Before submitting the PR, please check following (checks which are not relevant may be ignored):

  • Commit message are well written. In addition to a short title, the commit message also explain why a change is made.
  • At least one commit message contains a reference Closes #<xxx> or Fixes #<xxx> (replace<xxx> with issue number)
  • Tests are added
  • KtLint format has been applied on source code itself and violations are fixed
  • CHANGELOG.md is updated
  • PR description added

Documentation is updated. See difference between snapshot and release documentation

@paul-dingemans

Copy link
Copy Markdown
Member

Tnx for your contribution. I will have a look after 1.0.1 is released. Functional change like a new rule have to wait to next minor release.

@paul-dingemans paul-dingemans added this to the 1.1 milestone Oct 10, 2023
@hanggrian

Copy link
Copy Markdown
Contributor Author

Hi Paul. I understand, thanks for your response. And also for pointing out the bracing difference between Kotlin and Android style guides.

@paul-dingemans paul-dingemans left a comment

Copy link
Copy Markdown
Member

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.

Comment thread CHANGELOG.md Resolved
Comment on lines +28 to +30
for (i in 1..10) return 0
while (true) return 0
do return 0 while (true)

Copy link
Copy Markdown
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants