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

argument-list-wrapping does not allow an inline block comment #926

Closed
hkurokawa opened this issue Sep 25, 2020 · 3 comments · Fixed by #927
Closed

argument-list-wrapping does not allow an inline block comment #926

hkurokawa opened this issue Sep 25, 2020 · 3 comments · Fixed by #927

Comments

@hkurokawa
Copy link

Expected Behavior

Expect this code not to cause any errors.

fun main() {
    someMethod(
        /* firstName= */ "John",
        /* lastName= */ "Doe",
        /* age= */ 30
    )
}

Observed Behavior

/Users/hkurokawa/temp/Test.kt:3:26: Argument should be on a separate line (unless all arguments can fit a single line) (experimental:argument-list-wrapping)
/Users/hkurokawa/temp/Test.kt:4:25: Argument should be on a separate line (unless all arguments can fit a single line) (experimental:argument-list-wrapping)
/Users/hkurokawa/temp/Test.kt:5:20: Argument should be on a separate line (unless all arguments can fit a single line) (experimental:argument-list-wrapping)

Steps to Reproduce

Save the above code as test.kt and run the below command.

ktlint --verbose --experimental ~/temp/test.kt

Your Environment

  • Version of ktlint used: 0.39.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): command line
  • Version of Gradle used (if applicable): N/A
  • Operating System and version: macOS 10.15.6
  • Link to your project (if it's a public repository): private repository

Remarks

Sometimes I want to use the parameter name as an inline comment at the call site, so that readers don't need to look at the method declaration to understand the parameter's purpose. Kotlin has named argument so this technique is useful only when we are calling Java methods from Kotlin code.

@hkurokawa
Copy link
Author

Thanks for the effective work!

@spatenotte
Copy link

Looks like a similar issue is happening in Ktlint 0.49.1, using the standard rules:
image

@paul-dingemans
Copy link
Collaborator

Looks like a similar issue is happening in Ktlint 0.49.1, using the standard rules:

No, that is not a similar issue. As you can see in your output, the "standard:comment-wrapping" rule is not allowing a block comment to be followed by a code element. This is intended behavior. See https://pinterest.github.io/ktlint/0.49.1/rules/standard/#comment-wrapping.
See how do i disable a rule if you want to disable that specific rule.

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

Successfully merging a pull request may close this issue.

4 participants