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

Indentation incorrect for multiline expression in an assignment after the declaration that contains a null coalesce operator #1165

Closed
eygraber opened this issue Jun 15, 2021 · 0 comments · Fixed by #1178

Comments

@eygraber
Copy link
Contributor

eygraber commented Jun 15, 2021

Coming from detekt/detekt#3863 as this appears to be a ktlint issue.

Expected Behavior

The following code should be treated as formatted correctly:

fun test() {
  val a: String = ""

  val someTest: Int?

  someTest =
    a
      .toIntOrNull()
      ?: 1
}

Observed Behavior

It is instead reformatted:

fun test() {
  val a: String = ""

  val someTest: Int?

  someTest =
    a
    .toIntOrNull()
    ?: 1
}

Steps to Reproduce

See ktlint-1165.zip

Your Environment

  • Version of ktlint used: 0.41.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): custom Gradle task (from README)
  • Version of Gradle used (if applicable): 7.1
  • Operating System and version: Ubuntu 20.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant