You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code fragment triggers no errors, provided that expectedIndentAfterOperators is off:
val value =1 to
2
Now, let's surround the expression (which is an infix function call) with parentheses, preserving the indent:
val value = (1 to
2)
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:
val value =
(1 to
2)
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:
funf() {
true||false
}
— unless those expressions are surrounded with parentheses, requiring an extra indent:
funf() {
(true||false)
}
From now on (1.2.1+), no extra indent will be required:
funf() {
(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 text was updated successfully, but these errors were encountered:
### What's done:
* From now on, parentheses (`LPAR`/`RPAR`) don't increment or decrement the
indent unless they're a part of a function declaration or a function call.
* Parentheses which just enclose an expression don't affect the indent at all.
* This fixes#1409.
* Don't change the indent for parentheses-enclosed expressions
### What's done:
* From now on, parentheses (`LPAR`/`RPAR`) don't increment or decrement the
indent unless they're a part of a function declaration or a function call.
* Parentheses which just enclose an expression don't affect the indent at all.
* The only exclusion to the above rule is an `LPAR` immediately followed by a newline
(in this special case the indent is still incremented).
* This fixes#1409.
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:
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).Environment information
The text was updated successfully, but these errors were encountered: