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

Rule: equals sign should be on same line #105

Closed
MyDogTom opened this issue Nov 21, 2017 · 1 comment
Closed

Rule: equals sign should be on same line #105

MyDogTom opened this issue Nov 21, 2017 · 1 comment

Comments

@MyDogTom
Copy link
Contributor

I would like to enforce this rule

When a property initializer does not fit on a single line, break after the equals sign (=) and use a continuation indent.

Source

Valid example

private val defaultCharset: Charset? =
        EncodingRegistry.getInstance().getDefaultCharsetForPropertiesFiles(file)

Violation example

private val defaultCharset: Charset?
        = EncodingRegistry.getInstance().getDefaultCharsetForPropertiesFiles(file)

I also would like to use same rule with functions.

Valid example

fun sum(a: Int, b: Int) = 
        a + b

Violation example

fun sum(a: Int, b: Int) 
        = a + b

PS. I'm happy to try implement it, if such PR is welcome.

@shyiko
Copy link
Collaborator

shyiko commented Nov 21, 2017

Hi @MyDogTom. Absolutely. I'm kinda surprised it's not enforced yet so PR is definitely more than welcome.

MyDogTom added a commit to MyDogTom/ktlint that referenced this issue Nov 22, 2017
Line break is allowed only after assignment (eg. equals sign)
Auto formatting is supported via simplistic approach by putting
same line break with same indent from left side to right side of assignment

Closes pinterest#105
orchestr7 pushed a commit to saveourtool/diktat that referenced this issue Jun 29, 2020
Line break is allowed only after assignment (eg. equals sign)
Auto formatting is supported via simplistic approach by putting
same line break with same indent from left side to right side of assignment

Closes pinterest/ktlint#105
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