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

Place class/fun parameters onto the same line when below max_line_length #188

Closed
gabrielittner opened this issue Apr 16, 2018 · 4 comments
Closed

Comments

@gabrielittner
Copy link
Contributor

When you got something like the following ktlint should unwrap the parameters of test2, test3 and test4 because they fit in one line.

    fun test1(a: A, b: B) {
        // ...
    }

    fun test2(
        a: A,
        b: B
    ) {
        // ...
    }

    fun test3(a: A,
        b: B
    ) {
        // ...
    }

    fun test4(a: A, b: B
    ) {
        // ...
    }

The current behavior in 0.21.0 is that test1 and test2 stay like they are. test3 and test4 are reformatted to look like test2.

@gabrielittner
Copy link
Contributor Author

Parameterless functions should also be reformatted to be single line.

    fun test5(
    ) {}

All of this also affects constructors.

@shyiko
Copy link
Collaborator

shyiko commented Feb 12, 2019

(somewhat) related to #251

@shyiko shyiko changed the title Unwrap parameters if short enough Place class/fun parameters onto the same line when below max_line_length Feb 12, 2019
@paul-dingemans
Copy link
Collaborator

Code samples below are already fixed in a version prior to 0.43.2

    fun test1(a: A, b: B) {
        // ...
    }

    fun test2(
        a: A,
        b: B
    ) {
        // ...
    }

    fun test3(a: A,
        b: B
    ) {
        // ...
    }

    fun test5(
    ) {}

Code sample below will be fixed by + PR #1331

    fun test4(a: A, b: B
    ) {
        // ...
    }

@paul-dingemans
Copy link
Collaborator

Will be covered by #1341 which is in progress. Completion is to be expected in Ktlint 0.46.0.

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

3 participants