-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WRONG_INDENTATION
: running mvn diktat:fix
adds whitespace to string literals
#1347
WRONG_INDENTATION
: running mvn diktat:fix
adds whitespace to string literals
#1347
Comments
Another example (from #811): fun checkScript() {
lintMethod(
"""
|val A = "aa"
""".trimMargin(),
)
} |
### What's done: * Added unit tests for mis-indented expression body functions. * Comparison failures now recognized by IDEA. * Content comparison deltas prevented from being wrapped when presented to the user (`columnWidth` increased from 80 to `Int.MAX_VALUE`, so deltas will no longer have any inline `<br/>`). * Failing tests (caused by #1347, skipped by default) can be re-enabled by running with `-Dtests.can.be.muted=true` * See #1330.
### What's done: * Running `mvn diktat:fix` with `WRONG_INDENTATION` rule enabled injects whitespace into multiline string literals. Now, unit tests were added which reproduce this behaviour.
### What's done: * Running `mvn diktat:fix` with `WRONG_INDENTATION` rule enabled injects whitespace into multiline string literals. Now, unit tests were added which reproduce this behaviour.
### What's done: * Running `mvn diktat:fix` with `WRONG_INDENTATION` rule enabled injects whitespace into multiline string literals. Now, unit tests were added which reproduce this behaviour.
Originally introduced with the fix for #766. The problem is caused by the wrong assumption that there can be no more than two Actually, there can be more, e.g., the 1st line in this literal: """
@Suppress("diktat")
fun foo() {
val a = 1
}
""".trimIndent() — which is
All these nodes get indented via |
### What's done: * Code cleaned up in preparation to fix #1347. * No logic is modified with this change.
### What's done: * `IndentationError` moved to a separate source file. * Top-level extensions moved from `IndentationRule.kt` to `StringUtils.kt`.
### What's done: * `IndentationError` moved to a separate source file. * Top-level extensions moved from `IndentationRule.kt` to `StringUtils.kt`.
### What's done: * `IndentationError` moved to a separate source file. * Top-level extensions moved from `IndentationRule.kt` to `StringUtils.kt`.
### What's done: * Code cleaned up in preparation to settle #1347. * No logic is modified with this change.
### What's done: * `IndentationError` moved to a separate source file. * Top-level extensions moved from `IndentationRule.kt` to `StringUtils.kt`.
@0x6675636b796f75676974687562 looks like this issues has been incorrectly closed by Github automation, because commit message contained |
Indeed, despite I was sure I changed the commit message. |
### What's done: * `DEFAULT_INDENT_SIZE` is no longer used directly, in favor of `IndentationConfig.indentationSize`. * `IndentationConfig.indentationSize` usages encapsulated where possible.
### What's done: * `DEFAULT_INDENT_SIZE` is no longer used directly, in favor of `IndentationConfig.indentationSize`. * `IndentationConfig.indentationSize` usages encapsulated where possible.
…wline ### What's done: * Now, only those `LITERAL_STRING_TEMPLATE_ENTRY` nodes which immediately follow a newline are indented. * Additionally, with this change, `trimIndent()` and `trimMargin(...)` calls are more reliably detected. * This fixes #1347.
…wline ### What's done: * Now, only those `LITERAL_STRING_TEMPLATE_ENTRY` nodes which immediately follow a newline are indented. * Additionally, with this change, `trimIndent()` and `trimMargin(...)` calls are more reliably detected. * This fixes #1347.
…wline ### What's done: * Minor code clean-up.
Consider this code fragment:
Whenever the code doesn't match the settings of DiKTat (i.e., in the above example, the body of the
code
expression uses continuation indent whileextendedIndentAfterOperators
is false), runningmvn diktat:fix
is expected to re-format the code.While doing so (particularly, when
WRONG_INDENTATION
check is on), it sometimes adds extra whitespace around and within string literals, i. e.@Suppress("diktat")
may become
@Suppress( " diktat " )
Moreover, the operation is not idempotent, so running
mvn diktat:fix
consecutively yet increases the amount of whitespace.Sometimes excessively long lines get wrapped, and this may even result in non-compilable code:
Screenshot:
Originally from this comment.
The text was updated successfully, but these errors were encountered: