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

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

Closed
thejeff77 opened this issue Nov 9, 2023 · 10 comments
Closed

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

thejeff77 opened this issue Nov 9, 2023 · 10 comments

Comments

@thejeff77
Copy link

thejeff77 commented Nov 9, 2023

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

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

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

Thanks for the assist @mateuszkwiecinski!

@thejeff77
Copy link
Author

thejeff77 commented Nov 14, 2023

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

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

@thejeff77
Copy link
Author

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

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

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

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

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.

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

3 participants