Skip to content
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

Blank lines exceptions #98

Closed
vRallev opened this issue Nov 3, 2017 · 2 comments
Closed

Blank lines exceptions #98

vRallev opened this issue Nov 3, 2017 · 2 comments

Comments

@vRallev
Copy link

vRallev commented Nov 3, 2017

With the upgrade to 0.11.1 some styles don't work anymore according to #65. But I find them really useful, e.g.

if (something) {
    doSomething1()
    doSomething1()
    doSomething1()
    doSomething1()

} else if (something1) {
    doSomething1()
    doSomething1()
    doSomething1()
    doSomething1()

} else {
    doSomething1()
    doSomething1()
}

I find the empty line useful for a better separation especially in longer chained if-else statements. Is there something I could do to allow this?

@shyiko
Copy link
Collaborator

shyiko commented Nov 3, 2017

How about

when {
    something -> {
        doSomething1()
        doSomething1()
        doSomething1()
        doSomething1()
    }
    something1 -> {
        doSomething1()
        doSomething1()
        doSomething1()
        doSomething1()
    }
    else -> {
        doSomething1()
        doSomething1()
    }
}

or better yet

when {
    something -> handleSomething()
    something1 -> handleSomething1()
    else -> handleSomethingElse()
}

?

Generally, if I find myself in a situation where a blank line is required to make code readable it usually means that it's too long and should be split.

P.S. https://github.com/shyiko/ktlint#how-do-i-suppress-an-error might be of interest but I strongly advise against it.

(I'm closing this issue as nothing is really broken but feel free to continue the discussion)

@shyiko shyiko closed this as completed Nov 3, 2017
@vRallev
Copy link
Author

vRallev commented Nov 3, 2017

Another example is a try-catch with multiple catch statements. There it becomes ugly :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants