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 chain-wrapping with elvis operator and comment #1055

Closed
axelfontaine opened this issue Jan 13, 2021 · 1 comment · Fixed by #1180
Closed

False positive for chain-wrapping with elvis operator and comment #1055

axelfontaine opened this issue Jan 13, 2021 · 1 comment · Fixed by #1180
Labels

Comments

@axelfontaine
Copy link

Expected Behavior

In IntelliJ, there is a quick fix to shorten the following code using the ?: operator:

val abc = getAbc()
if (abc == null) {
    // Comment
    return Xyz()
}

into

val abc = getAbc()
    ?: // Comment
    return Xyz()

As this was how IntelliJ transformed it, it should be considered good style.

Observed Behavior

Instead klint then complains about this with chain-wrapping myfile.kt:130 Line must not end with "?:"

Steps to Reproduce

See above

Your Environment

  • Version of ktlint used: 0.40.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): API via code-assert
  • Operating System and version: Win10 x64 20H2
@Tapchicoma Tapchicoma added the bug label Jan 14, 2021
@Tapchicoma
Copy link
Collaborator

Could reproduce it.

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

Successfully merging a pull request may close this issue.

2 participants