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

False positive for standard:discouraged-comment-location #2364

Closed
vanniktech opened this issue Nov 19, 2023 · 6 comments
Closed

False positive for standard:discouraged-comment-location #2364

vanniktech opened this issue Nov 19, 2023 · 6 comments

Comments

@vanniktech
Copy link
Contributor

The following gets flagged:

        start(
          currentMeditation = resumed,
          beginningSound = null, // Just leads to confusion.
        )

The error is placed at the start of //: A comment in a 'value_argument_list' is only allowed when placed on a separate line (standard:discouraged-comment-location)

Either I don't understand the exception message or I believe this is a false positive. The function signature looks like this:

private fun start(
    currentMeditation: CurrentMeditation,
    beginningSound: Sound?,
)
@vanniktech
Copy link
Contributor Author

Some more mentions that I have:

val options = listOf(
  data?.encodedSchemeSpecificPart?.takeWhile { it != '?' }, // Such as "49.631974,8.376489?q=49.631974,8.376489".
  data?.encodedQuery?.removePrefix("q="), // Such as "q=49.631974,8.376489".
)
val COLORS = listOf(
  0xFFFF0000.color, // Red.
  0xFFFFFF00.color, // Yellow.
  0xFF00FF00.color, // Green.
  0xFF00FFFF.color, // Cyan.
  0xFF0000FF.color, // Blue.
  0xFF800080.color, // Purple.
  0xFFFF00FF.color, // Magenta.
  0xFFFFFFFF.color, // White.
  0xFF808080.color, // Gray.
  0xFF000000.color, // Black.
)

I tried to disable that rule ktlint_standard_discouraged-comment-location=disabled and then I run again into #2338
Then it seems like I also need to ktlint_standard_class-signature=disabled which is a bummer because looking at it, I'd want it. Isn't it possible for ktlint to reuse the code while still allowing a rule to be disabled? It really seems like a flaw in the design system from the user perspective.

@vanniktech
Copy link
Contributor Author

Side note: Why does ktlint_standard_class-signature=disabled work when the rule in the documentation is listed as experimental? Should not it be ktlint_experimental_class-signature=disabled?

@paul-dingemans
Copy link
Collaborator

See faq https://pinterest.github.io/ktlint/latest/faq/#why-does-ktlint-discourage-certain-comment-locations and https://pinterest.github.io/ktlint/latest/faq/#why-is-a-rule-skipped-when-i-disable-some-other-rule and #2338

Why does ktlint_standard_class-signature=disabled work when the rule in the documentation is listed as experimental? Should not it be ktlint_experimental_class-signature=disabled

See https://pinterest.github.io/ktlint/latest/rules/experimental/

@paul-dingemans paul-dingemans closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2023
@vanniktech
Copy link
Contributor Author

I still don't understand why putting ktlint_standard_class-signature=disabled in the .editorconfig file works when the rule is stated as experimental and I'd assume that I need to put ktlint_experimental_class-signature=disabled.

@paul-dingemans
Copy link
Collaborator

I still don't understand why putting ktlint_standard_class-signature=disabled in the .editorconfig file works when the rule is stated as experimental and I'd assume that I need to put ktlint_experimental_class-signature=disabled.

Up until ktlint 0.47.x there were two different rulesets: standard and experimental. Moving rules from experimental to standard resulted in breaking changes as the rule identifier changed from experimental:some-rule to standard:some-rule. Only the experimental rule set could contain experimental rules. Starting from 0.48.x rules are individually marked as experimental. So all rules provided by ktlint are located in the ruleset standard. Some rules in the standard rule set are marked as experimental.

@vanniktech
Copy link
Contributor Author

Thanks for the explanation!

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

2 participants