question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent indentation of "when" branches

See original GitHub issue

It’s possible to get three different indent levels in a single when statement. Ktfmt output:

fun test(x: String) {
  when (x) {
    "foo" ->
        synchronized(this) {
          println("A statement")
          println("Another statement")
        }
    "bar" ->
    // A comment
    println("Okay")
    "baz" -> {
      println("Just a statement")
      println("And another")
    }
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sgrimmcommented, Mar 5, 2020

Yeah, that’s fair; the lack of distinction between continuation and block indent makes their intent ambiguous. My preference is for block indent but like I said, I totally acknowledge I’m bikeshedding at the moment and am happy with the fix for the second case.

1reaction
sgrimmcommented, Mar 5, 2020

Yeah, that’s better now. I would personally prefer block indent for single-statement when branches so the indentation doesn’t change if you add braces and is consistent when you have a mix of block and single-statement branches, but I am completely on board with the idea that ktfmt should be opinionated even if I don’t agree with 100% of its opinions. I agree that only the second case was clearly a bug. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is `git show` indentation inconsistent? - Stack Overflow
When I execute git show I'm seeing inconsistent indentation. The file uses a mix of "8-space" tabs and spaces, and I've run git...
Read more >
Python: inconsistent use of tabs and spaces in indentation
The Python “TabError: inconsistent use of tabs and spaces in indentation” error is raised when you try to indent code using both spaces...
Read more >
New rule: Inconsistent indentation #264 - ansible/ansible-lint
If indentations in the YAML file(s) that are being analyzed are inconsistent (e.g. one task in the same file is indented with 3...
Read more >
Inconsistent indentation in diff discussion notes - GitLab FOSS
When the header (with the username and timestamp) overflows to two lines, it bumps down the note body, and this causes the body...
Read more >
Fix inconsistent indentation between @code - @endcode ...
While working on that issue it is noticed that we have the inconsistent indentation between @code - @endcode blocks.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found