jeremymailen / kotlinter-gradle

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

Allow disabling of [standard:discouraged-comment-location] #351

Closed thejeff77 closed 10 months ago

thejeff77 commented 10 months ago

The new v4 cannot auto-fix, nor will support/allow disabling the rule for this:

[standard:discouraged-comment-location] A comment in a 'value_parameter_list' is only allowed when placed on a separate line

Suffice to say, its annoying as s***.

Kindly allow an option to disable this in config. When adding to .editorconfig, it doesn't work and gives a warning it is not supported:

Screenshot 2023-11-09 at 7 09 00 AM

mateuszkwiecinski commented 10 months ago

According to https://pinterest.github.io/ktlint/1.0.1/rules/configuration-ktlint/#disabled-rules a proper syntax is:

ktlint_standard_discouraged-comment-location = disabled

and not = off

(make sure you kill the gradle daemon (./gradlew --stop), to ensure .editorconfig changes are properly picked up)

thejeff77 commented 10 months ago

Thanks for the quick feedback!

Seem to be getting this after changing it and re-running:


java.lang.IllegalStateException: Skipping rule(s) which are depending on a rule which is not loaded. Please check if you need to add additional rule sets before creating an issue.
  - Rule with id 'RuleId(value=standard:if-else-wrapping)' requires rule with id 'RuleId(value=standard:discouraged-comment-location)' to be loaded
jeremymailen commented 10 months ago

Thanks for the assist @mateuszkwiecinski!

thejeff77 commented 10 months ago

@jeremymailen did you see that I responded and the suggestion didn't work before you closed this?

I get this error now when running ./gradlew lintKotlin apparently I can't just disable this rule.

setting this doesn't help either: ktlint_standard_if-else-wrapping = disabled

jeremymailen commented 10 months ago

@thejeff77 this is a different problem. ktlint is seeing your specification, but certain rules are dependent on others. See issue discussion here: https://github.com/pinterest/ktlint/issues/2338

thejeff77 commented 10 months ago

@jeremymailen I read that, I'm not sure what the resolution is. Do you have any recommendations?

I'd argue that if a solution doesn't solve the issue and in-fact breaks the tool, it isn't a full solution..

thejeff77 commented 10 months ago

Here's my full config if it helps, and the linting is broken:

[*.{kt,kts}]
max_line_length = off
ktlint_standard_discouraged-comment-location = disabled
ktlint_standard_if-else-wrapping = disabled
jeremymailen commented 10 months ago

I think the solution is only specifying how to correctly get the setting to "take" and doesn't speak to which other rules are required. Neither I nor @mateuszkwiecinski are committers on https://github.com/pinterest/ktlint and that's the logic that's causing you trouble.

thejeff77 commented 10 months ago

@jeremymailen ok thanks.. I'll post over there. That's helpful. Appreciate the quick replies. I really need to figure out how to turn this off in a way that actually works.

jeremymailen commented 10 months ago

I found that setting ktlint_code_style to intellij_idea went a long way towards making the lint enforcement acceptable. Like you, I don't find this idea of dependent lint rules to be user friendly and can a become a blocker for adoption.