Closed roschlau closed 7 months ago
A lot of details are missing in your report, so I have to guess what is happening in your case.
What version of Ktlint is used by your spotless version? What version of the ktlint-intellij-plugin
are you using?
One thing that you can try, is to set the ktlint_code_style
property in .editorconfig' to value
intellij_idea`. Read more in ktlint documentation.
I've tried spotless with ktlint version 1.1.1, and the ktlint intelliJ plugin is in version 0.20.0. If there's any more info that would help, let me know!
Yeah, setting the code style to intellij_idea
fixes it, but as far as I understand it just disables that rule completely, right? I do agree with the rule in general (at least as documented) and would like to keep it enabled, if possible. It just seems that for some reason it's not correctly checked. Unless I'm mistaken about that!
Next thing that you can try, is to set code style explicitly to ktlint_official
in .editorconfig
. But, I am not sure whether Spotless does respect that.
The plugin is still on 1.1.0
but that could not explain this behavior.
Okay, after a few more tests, now spotless also reports the same error. That's... Weird, not sure what was going on the first time. Then I guess my question is why the rule is triggering, since I don't believe it should, but that then has nothing to do with the IntelliJ plugin, so I'll close this issue here. Thanks for the help, and sorry for bothering you with a non-issue!
Edit: Now I found even that problem - I previously overlooked that the rule by default also triggers on exceeding a certain number of function parameters, even if the signature would fit the max line length. So turns out I was just being very dense here.
I have this code in a Kotlin file:
And ktlint reports this error:![image](https://github.com/nbadal/ktlint-intellij-plugin/assets/16798225/6a6d9244-3f8a-4396-a2b4-02986eb25aab)
Seems weird to me, since afaict from the docs, this rule should only trigger if the full function signature doesn't fit within the max-line-length rule (which is at the default 140 for us). I'd prefer not to break the signature into multiple lines here.
Is there anything I can do to get more info on why this rule is triggering here, and how to prevent it? Spotless with ktlint doesn't seem to complain about this file.