Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling rule not working #336

Closed
vendelieu opened this issue Jul 23, 2023 · 12 comments
Closed

Disabling rule not working #336

vendelieu opened this issue Jul 23, 2023 · 12 comments

Comments

@vendelieu
Copy link

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
Copy link
Owner

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

@vendelieu
Copy link
Author

I even tried after pc restarting, still not working

@jeremymailen
Copy link
Owner

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
Copy link

MV-GH commented Sep 28, 2023

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

@mxkmn
Copy link

mxkmn commented Nov 11, 2023

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
Copy link

ygnessin commented Nov 21, 2023

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
Copy link

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
Copy link
Owner

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

@duncte123
Copy link

@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
Copy link

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

@jeremymailen
Copy link
Owner

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
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants