Inconsistent indentation of "when" branches
See original GitHub issueIt’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:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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!