Hi there, I'm struggling a lot with ktlint when tr...
# ktlint
x
Hi there, I'm struggling a lot with ktlint when trying to format my code. If I run an Android Studio code reformat of a long if statement, it formats the if as Kotlin Official Code Style, however ktlint complains about an unexpected indentation:
Copy code
if (records.containsKey(AdvRecord.TYPE_UUID128) && Arrays.equals(
        Config.MYOWN_GATT_SERVICE_RAW,  // <-- Unexpected indentation (expected 12, actual 16)
        AdvRecord.getServiceUUID128(records[AdvRecord.TYPE_UUID128]!!) // <-- Same as above
    ) // <-- Unexpected indentation (expected 8, actual 12)
) {
    ...
}
However, if I change manually to the expected result,
ktlintFormat
complains about the same lines to be changed into the previous code indentation again. I don't understand anything. What I'm trying to achieve is Android Studio IDE code reformat fits with ktlint criteria, and somehow they're unsynced now. I'm using the latest gradle plugin:
Copy code
id "org.jlleitschuh.gradle.ktlint" version "9.4.1"
I have even tried to run
ktlint --android applyToIDEAProject
to apply project specific code style, but the problem persist. Any idea how to solve this guys?
t
Have you tried to move
Arrays.equals(
to next line?
r
that’s a known bug, I think is already fixed on master, you could try the latest snapshot. If you wanna temporary suppress it, you could also try to wrap this snippet into
Copy code
/* ktlint-disable parameter-list-wrapping */
... your snippet ...
/* ktlint-enable parameter-list-wrapping */
x
@tapchicoma I tried that, but it still fails. Related to @romtsn suppression suggestion, if
Array.equals
remains on the same line, it works. However, moving that statement to the next line, the suppression doesn't affect.
638 Views