GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add multiline-loop to complement multiline-if-else by hanggrian · Pull Request #2298 · ktlint/ktlint

Conversation

@hanggrian

@hanggrian hanggrian commented Oct 9, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

  • Snapshot documentation in case documentation is to be released together with a code change
  • Release documentation in case documentation is related to a released version of ktlint and has to be published as soon as the change is merged to master
  • In case of adding a new rule, it needs to be added to experimental rules documentation

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hanggrian
Add multiline-loop to complement multiline-if-else
33686d6
@paul-dingemans

paul-dingemans commented Oct 10, 2023

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

hanggrian commented Oct 11, 2023

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hanggrian
Add multiline-loop changelog and documentation (#2298)
7d3a2de
paul-dingemans
paul-dingemans requested changes Oct 14, 2023
View reviewed changes

@paul-dingemans paul-dingemans left a comment

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread CHANGELOG.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread documentation/snapshot/docs/rules/experimental.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...et-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRule.kt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...et-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRule.kt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...et-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRule.kt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...tandard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRuleTest.kt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...tandard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRuleTest.kt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...tandard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRuleTest.kt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...et-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRule.kt Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...tandard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/MultiLineLoopRuleTest.kt Outdated
Comment on lines +28 to +30
for (i in 1..10) return 0
while (true) return 0
do return 0 while (true)

@paul-dingemans paul-dingemans Oct 14, 2023

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
hanggrian and others added 2 commits October 19, 2023 02:30
@hanggrian
Rename multiline-loop class
30556ec
@paul-dingemans
Merge branch 'master' into master
6b5e939
@paul-dingemans
paul-dingemans merged commit 05aa8a0 into ktlint:master Nov 16, 2023
@paul-dingemans paul-dingemans mentioned this pull request Nov 16, 2023
Multiline if-else rule could also consider for and while-loop #2223
Closed
@paul-dingemans paul-dingemans added the feature changelog label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@paul-dingemans paul-dingemans paul-dingemans requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

feature changelog

Projects

None yet

Milestone

1.1

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@hanggrian @paul-dingemans
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.