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

Statement may not start or end on same line as start/end of block #1938

Closed
paul-dingemans opened this issue Apr 12, 2023 · 3 comments · Fixed by #2001
Closed

Statement may not start or end on same line as start/end of block #1938

paul-dingemans opened this issue Apr 12, 2023 · 3 comments · Fixed by #2001
Labels
Milestone

Comments

@paul-dingemans
Copy link
Collaborator

paul-dingemans commented Apr 12, 2023

Given code sample below:

fun foo1() { if (true) {
        // do something
    }
}

fun foo2() {
    if (true) {
        // do something
    } }

then it should be formatted as:

fun foo1() {
    if (true) {
        // do something
    }
}

fun foo2() {
    if (true) {
        // do something
    }
}

This issue should be covered by same (new) rule as for #1078

@atulgpt
Copy link
Contributor

atulgpt commented May 7, 2023

Hi, @paul-dingemans I have added my draft PR for early review. Given this is my first PR something might be wrong 😅

Also let me know if it needs to handle all the block codes, like blocks of class, object, when, and if. I am not sure if some existing rules already handle those

@atulgpt
Copy link
Contributor

atulgpt commented May 7, 2023

Hi, @paul-dingemans for adding documentation and updating CHANGELOG.md is there any documentation?

@paul-dingemans
Copy link
Collaborator Author

Hi, @paul-dingemans I have added my draft PR for early review. Given this is my first PR something might be wrong 😅

Also let me know if it needs to handle all the block codes, like blocks of class, object, when, and if. I am not sure if some existing rules already handle those

Handle this generically for all blocks. I would expect that if you just implement this for element type BLOCK that it covers all of that. But please do add sufficient unit tests to validate.

Hi, @paul-dingemans for adding documentation and updating CHANGELOG.md is there any documentation?

There are no docs about how to document.

The CHANELOG.DOC contains a section Unreleased at the top where you have to add the rule under sub section Added. See older release notes for examples.

In sub directory docs you will find the documentation which is published on https://pinterest.github.io/ktlint/. As a new rul should be marked as Rule.Experimental it should also be documented in file experimental.md. Please, follow the same approach as for other rule.

# 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.

2 participants