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
Ktlint successfully formats a block comment at the end of a statement into a line comment:
funmain() {
println("test") // test
}
Observed Behavior
Ktlint fails with:
14:36:33.661 [pool-1-thread-1] WARN com.pinterest.ktlint.rule.engine.internal.CodeFormatter -- Format was not able to resolve all violations which (theoretically) can be autocorrected in file Main.kt
Tnx for reporting. There is something strange going on, and your example perfectly demonstrates that. A quick investigation lead to following observations that I will have to look into later:
Running ktlint without format and code style intellij_idea on the code example leads to violation:
Foo.kt:2:21: A single line block comment after a code element on the same line must be replaced with an EOL comment (standard:comment-wrapping)
Although this remark seems correct, it is odd that it is reported by rule comment-wrapping. The fix applied by this rule is changing some whitespace element, but not the comment markers. So this confirms that the format does not work. The reported violation has to be validated, and description should match with the fix that can be applied.
Running ktlint without format and code style ktlint_official on the code example leads to violations:
Foo.kt:2:21: A single line block comment after a code element on the same line must be replaced with an EOL comment (standard:comment-wrapping)
Foo.kt:2:21: Replace the block comment with an EOL comment (standard:no-single-line-block-comment)
15:57:42.748 [main] WARN com.pinterest.ktlint.cli.internal.KtlintCommandLine -- Lint has found errors than can be autocorrected using 'ktlint --format'
```
Now we have two rules reporting a violation about the block comment. The violation reported by no-single-line-block-comment has the autocorrect fix that actually replaces the block comment by an EOL comment. This rule is by default only enabled in the `ktlint_official` code style, but it can be enabled explicitly for other code styles as well.
Expected Behavior
Ktlint successfully formats a block comment at the end of a statement into a line comment:
Observed Behavior
Ktlint fails with:
Steps to Reproduce
.editorconfig
Note: This bug only occurs when
ktlint_code_style
is set tointellij_idea
. When it's set toktlint_official
, ktlint formats the file correctly.Main.kt
Environment
The text was updated successfully, but these errors were encountered: