The following code fragment triggers no errors, provided that expectedIndentAfterOperators is off:
Now, let's surround the expression (which is an infix function call) with parentheses, preserving the indent:
DiKTat will report the following errors:
[WRONG_INDENTATION] only spaces are allowed for indentation and each indentation should equal to 4 spaces (tabs are not allowed): expected 8 but was 4
[WRONG_INDENTATION] only spaces are allowed for indentation and each indentation should equal to 4 spaces (tabs are not allowed): expected 8 but was 4
Strangely, if we move the expression onto the next line (and increment the indent), the errors immediately go away:
The issue is caused by the incomplete implementation of ExpressionIndentationChecker as a part of #75 (see 7d913ed).
Note
The fix for this issue will also have the following side-effect. Previously (1.2.0), DiKTat would format expressions wrapped before an infix function (see also #1340) like this:
fun f() {
true
|| false
}
— unless those expressions are surrounded with parentheses, requiring an extra indent:
fun f() {
(true
|| false)
}
From now on (1.2.1+), no extra indent will be required:
fun f() {
(true
|| false)
}
— which is still incorrect, but will be fixed as a part of #1340.
Environment information
- diktat version: 1.2.0
- build tool (maven/gradle): Maven
- how is diktat run (CLI, plugin, etc.): Maven plug-in
- kotlin version: 1.7.0
- operating system: Windows
The following code fragment triggers no errors, provided that
expectedIndentAfterOperatorsis off:Now, let's surround the expression (which is an infix function call) with parentheses, preserving the indent:
DiKTat will report the following errors:
Strangely, if we move the expression onto the next line (and increment the indent), the errors immediately go away:
The issue is caused by the incomplete implementation of
ExpressionIndentationCheckeras a part of #75 (see 7d913ed).Environment information