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

New Rule Proposal: square-bracket-spacing #2543

Closed
mgroth0 opened this issue Feb 8, 2024 · 0 comments · Fixed by #2555
Closed

New Rule Proposal: square-bracket-spacing #2543

mgroth0 opened this issue Feb 8, 2024 · 0 comments · Fixed by #2555
Labels
Milestone

Comments

@mgroth0
Copy link
Contributor

mgroth0 commented Feb 8, 2024

Currently, with the standard ruleset:

class SomeClass() {
    operator fun set(
        a: Int,
        b: Int,
        c: Int,
    ) = Unit

    fun set(
        a: Double,
        b: Double,
    ) = Unit
}

fun someFunction() {
    SomeClass() [ 1, 2 ] = 3 // allowed
    SomeClass().set( 1.0, 2.0 ) // Unexpected spacing after "(" (standard:paren-spacing)
    SomeClass().set(1.0, 2.0) // allowed
}

Expected Rule behavior

SomeClass() [ 1, 2 ] = 3

Becomes

SomeClass()[1,2] = 3

I propose square-bracket-spacing have the same behavior as paren-spacing, but with square brackets.

Additional information

  • Current version of ktlint: 1.1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants