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

Adding experimental rule for detecting first line blank in method block #474

Conversation

sowmyav24
Copy link
Contributor

This experimental rule addresses issue Issue #440
In addition to checking for first line blank in a method block, it will check for any first blank line in code blocks of the method.Please let me know if the subsequent code blocks in the method need to be ignored from this check.

Due to this new rule, there were violations reported in the code. Have fixed them also.

This is same as PR #461.

@shashachu
Copy link
Contributor

In addition to checking for first line blank in a method block, it will check for any first blank line in code blocks of the method

Does this mean that

fun bar() {
    if (something) {

        foo()
    }
}

will not change during formatting, but

fun bar() {

    if (something) {

        foo()
    }
}

will format to

fun bar() {
    if (something) {
        foo()
    }
}

?

If so, that inconsistency seems unexpected.

@sowmyav24
Copy link
Contributor Author

fun bar() {
    if (something) {

        foo()
    }
}

would also format to

fun bar() {
    if (something) {
        foo()
    }
}

Added a test for this scenario also

@sowmyav24 sowmyav24 force-pushed the no-first-line-blank-in-method-block-experimental-rule branch from 3f1381c to fc88b61 Compare June 11, 2019 00:07
@shashachu
Copy link
Contributor

looks good to me- thanks!

@shashachu shashachu merged commit 577bd48 into pinterest:master Jun 11, 2019
@sowmyav24 sowmyav24 deleted the no-first-line-blank-in-method-block-experimental-rule branch June 12, 2019 00:34
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 12, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 12, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 12, 2019
sowmyav24 added a commit to sowmyav24/ktlint that referenced this pull request Jun 12, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants