I'm using ktlint 0.50.0, with Spotless 6.20.0, on AGP 8.1.0. Running spotless as a PreCommit Git hook. Due to the existence of too many old code, I'm trying to disable some rules. The one that gives me trouble is the "max_line_length".
How can I disable it?
I created a simple ".editorconfig" file (I want to get all the defaults for the rest of the rules):
root = true
[*]
[*.java]
[{*.gradle.kts,*.kt,*.kts,*.main.kts}]
ktlint_standard_comment-wrapping = disabled # this one is successfully disabled
So, I tried all possible combinations, also tried the property on different levels:
max_line_length = off # as property
max_line_length = 2147483647 # using Int.MAX_VALUE
ktlint_standard_max-line-length = disabled
ktlint_standard_max_line_length = disabled
ktlint_standard_max-line-length = off
ktlint_standard_max_line_length = off
I don't want to use in-file ktlint comments, as this requires changes in the files... and I do not want to go there.
When trying to commit, I'm always getting the Max line Length exceeded error...
Any suggestion on how can I disable this specific rule?
What am I missing?
Any suggestion...
The only thing that worked for me was to "overwrite" those parameters through the Spotless
editorConfigOverride
API. Changing:to:
Note the
2147483647
value, this isInt.MAX_VALUE
. I checked in the ktlintMaxLineLengthEditorConfigProperty
andCommentWrappingRule
code that this should disable it... and it worked.I completely removed the
.editorconfig
file, as those were the only "custom" options.Before that, I also tried setting a higher value for the
max_line_length
in the.editorconfig
file... on every level and it did not work, it was always defaulting to 150.