Jonathan Lennox
10/02/2023, 4:49 PMclass Test(
/** The width. */
val width: Int,
/** The height */
/* XXX We should be able to figure out the height automatically. */
val height: Int
)
Whatever I try the XXX comment triggers discouraged-comment-location
. Any suggestions?Paul Dingemans
10/02/2023, 4:54 PMJonathan Lennox
10/02/2023, 5:13 PMA comment in a 'value_parameter' is only allowed when placed on a new line before this element (standard:discouraged-comment-location)
but I don't understand what it wants - I've tried putting blank lines in various placesJonathan Lennox
10/02/2023, 5:14 PM--format
isn't able to autocorrect this.Paul Dingemans
10/02/2023, 7:33 PMJonathan Lennox
10/02/2023, 7:43 PMJonathan Lennox
10/02/2023, 7:43 PMPaul Dingemans
10/02/2023, 8:53 PMsrc/main/kotlin/Foo.kt:5:5: A comment in a 'value_parameter' is only allowed when placed on a new line before this element (standard:discouraged-comment-location)
src/main/kotlin/Foo.kt:5:5: a block comment may not be preceded by a KDoc. Reversed order is allowed though when separated by a newline. (standard:no-consecutive-comments)
src/main/kotlin/Foo.kt:5:5: Replace the block comment with an EOL comment (standard:no-single-line-block-comment)
s
I would say that those should be descriptive enough. So, I will take no further actions on this.Jonathan Lennox
10/02/2023, 8:53 PMJonathan Lennox
10/02/2023, 8:53 PMJonathan Lennox
10/03/2023, 3:29 PMktlint_code_style = intellij_idea
-- maybe the other warnings only show up in ktlint style?Paul Dingemans
10/03/2023, 7:09 PMktlint_official
as you did not mention anything about it. I just had another look on it. The validation message is not correct in your situation. The new message will be A (block or EOL) comment inside or on same line after a 'value_parameter' is not allowed. It may be placed on a separate line above.
Still this message is not really clear in your specific example but it is the best I can come up now.
There is really something weird going on in the kotlin compiler. It actually makes a difference whether the block comment is placed before or after the KDoc. When it is placed before the KDoc, it is contrary to the KDoc not a part of the value parameter. When placed after the KDoc, both the KDoc and block comment are part of the value parameter.
The latter situation is difficult to handle in certain rules. Because it is really unusual to do so, this situation is just blocked by the rule so that other rules do not have to take this into account.
So, in your code you can switch the order of the block comment and kdoc. It is a bit unstatisfying, but not really worth the effort to fix.Paul Dingemans
10/03/2023, 7:23 PM