pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.07k stars 504 forks source link

parameter-list-wrapping disable is not respected #2614

Closed rsmith20 closed 3 months ago

rsmith20 commented 3 months ago

Expected Behavior

The following code

fun getList(): List<Int> {
    return listOf(
        1,
        2, 3,
    )
}

should be unchanged after formatting given the .editorconfig below.

Observed Behavior

Instead the following code is produced

fun getList(): List<Int> {
    return listOf(
        1,
        2, 
        3,
    )
}

Steps to Reproduce

Use latest CLI ktlint or the ktlint intelliJ plugin on a file with this code. Both repro.

Your Environment

Kotlin style rules that get handled by intelliJ and ktlint.

[{.kt,.kts}]

ktlint specific rules

ktlint_code_style = intellij_idea ktlint_standard_parameter-list-wrapping = disabled


(A large editor config produced the problem initially but this config repros)
* Operating System and version: Macos M3 Sonoma 14.3
paul-dingemans commented 3 months ago

Most likely you have disabled the wrong rule. It is the argument-list-wrapping rule that is transforming your code. Note that since 1.2.x there is a configuration parameter which you can set to change the behavior of this rule. See https://pinterest.github.io/ktlint/latest/rules/standard/#argument-list-wrapping

rsmith20 commented 3 months ago

Confirmed, disabling argument-list-wrapping instead of parameter-list-wrapping fixed the issue. Thanks!