Skip to content

block-comment-after-open

all languagesstyleno fixdefault: offkotlin/ktlint

Reports a block comment that follows an opening token on its line and ends the line (if (a) { /* note */). The tokens are the option after (default {). A line comment there, and a block comment with code after it on the line, are not reported.

The style keeps a block comment from ending the line of an opening brace. A comment on a line of its own above the first statement says clearly which statement it describes.

To fix, move the comment to its own line.

Reported
fun f(a: Int) {
if (a > 1) { /* big */
g()
}
if (a > 2) { // line comment
...
lint:
rules:
block-comment-after-open:
level: warn # off (default), warn, error
options:
after: ["{"]
Option Type Default Description
after list ["{"] The tokens a block comment must not follow on their line.

Enabled by the presets: kotlin/ktlint.

Suppress one line with sudsy-disable-next-line block-comment-after-open in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ktlint wrapping full