Open icemachined opened 2 years ago
Reg. No. 2, from IDEA standpoint, you get a relative indent of 8 (an absolute indent of 16), because IDEA combines a single indent within an if()
-statement (CONTINUATION_INDENT_IN_IF_CONDITIONS
is false
) with a single indent of a chained function call (CONTINUATION_INDENT_FOR_CHAINED_CALLS
is false
):
val prevComment = if (valueParameterNode.siblings(forward = false)
.takeWhile { it.elementType != EOL_COMMENT && it.elementType != BLOCK_COMMENT }
.all { it.elementType == WHITE_SPACE }
) {
// block body
}
Minimal repro:
if (""
.isBlank()) {
// block body
}
while (""
.isBlank()) {
// block body
}
do {
// block body
} while (""
.isBlank())
This behaviour is documented in this Wiki section.
No. 1 is a separate matter. While all these are correctly formatted (IDEA and diKTat behave consistently):
if (true &&
true &&
false) {
return
}
if (true ||
true ||
false) {
return
}
if (true &&
true ||
false) {
return
}
— here's the minimal repro:
if (true ||
true &&
false) {
return
}
Apparently, this is something related to operator priorities (see 3.5 Line length), since adding parentheses around the 1st two booleans immediately "fixes" the issue (and modifies the logic):
if ((true ||
true) &&
false) {
return
}
Another minimal repro:
if (1 +
2 *
3 == 7) {
return
}
And two more, w/o any if()
-statements:
val a = true ||
true &&
true
val b = 1 +
2 *
3
In this latter case, IDEA would disregard any operator priorities and simply use a (continuation) indent of 8.
Describe the bug
Expected behavior
there should be no error after idea style applying
Observed behavior
Steps to Reproduce
If you apply idea formatting in
KdocComments
you have the following piece of codebut diktat report error as far as it expect continuation indent in the last line of if expression like this
If you apply idea formatting in KdocComments you have the following piece of code with 16 spaces in second line
but diktat report error as far as it expect 12 spaces instead 16 as below
Environment information