jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle
Apache License 2.0
597 stars 50 forks source link

Disabling rule not working #336

Closed vendelieu closed 10 months ago

vendelieu commented 1 year ago

This is my .editorconfig file:

root = true

[*.{kt,kts}]
max_line_length = 140
indent_size = 4
insert_final_newline = true
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ktlint_standard_multiline-if-else = disabled

And disabling multiline if-else not working.

I'm using 3.15 version.

jeremymailen commented 1 year ago

Try restarting the gradle daemon. Sometimes it doesn't doesn't see the .editorconfig change as a change to build inputs. See #327

vendelieu commented 1 year ago

I even tried after pc restarting, still not working

jeremymailen commented 1 year ago

Definitely shouldn't need to restart your computer -- just the Gradle daemon sometimes. The bug with recognizing editorconfig changes persists and needs to get fixed.

I was able to restart the gradle daemon and configure it to ignore multi-line if then else:

Screenshot 2023-08-12 at 10 26 41 PM

Where is your .editorconfig file located? Are you on kotlinter version 3.15.0?

MV-GH commented 1 year ago

Had the same issue, ./gradlew --stop solved it for me

mxkmn commented 10 months ago

For everyone like me: use disabled, not unset.

The syntax in kotlinter requires you to call the string ktlint_[standard/experimental]_rule-name = disabled, not ktlint_[standard/experimental]_rule-name = unset.

And for now you should use ./gradlew --stop to rescan .editorconfig file.

ygnessin commented 10 months ago

For anyone else running into this, another option is to disable with -Dorg.gradle.daemon=false when you run the task. For example

./gradlew lintKotlin -Dorg.gradle.daemon=false
./gradlew formatKotlin -Dorg.gradle.daemon=false
duncte123 commented 10 months ago

Stopping the gradle deamon and running without one did not work for me. As a last resort I just disabled the plugin. Plugin version: 4.1.0 (upgraded from 3.13.0) OS (in case that somehow matters): Ubuntu 22.04.3

jeremymailen commented 10 months ago

@duncte123 what's your editorconfig look like and which rules are you expecting to disable?

duncte123 commented 10 months ago

@duncte123 what's your editorconfig look like and which rules are you expecting to disable?

This my my editorconfig, I tried to match the settings I had set with the gradle configuration but even disabling all rulesets still validates them

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

[gradlew]
end_of_line = lf

[*.{kt,kts}]
ktlint_code_style = ktlint_official
ktlint_standard = enabled
ktlint_experimental = disabled 
ktlint_custom-rule-set = disabled 
klint_standard_no-wildcard-imports = disabled
klint_standard_function-signature = disabled
klint_standard_trailing-comma-on-call-site = disabled
klint_standard_multiline-expression-wrapping = disabled
ygnessin commented 10 months ago

@duncte123 you have typos in your editor config. Your disabled rules should begin with ktlint_ not klint_

jeremymailen commented 10 months ago

Yes, that seems to be the case.

Another test you can do is run the ktlint command line on your same project and editorconfig and see if you get the same result. That can often tell you if you're running into a gradle plugin issue or if a more fundamental issue is occurring with ktlint.

duncte123 commented 10 months ago

@duncte123 you have typos in your editor config. Your disabled rules should begin with ktlint_ not klint_

Oh, thanks for spotting that. Not sure how I missed that.

Fixing those typos in combination with disabling the daemon makes it work like a charm again, thanks!