This rule flags single-line block comments (/* ... */) that could be more appropriately replaced by end-of-line (EOL) comments (// ...). A violation occurs when a block comment starts and ends on the same line and is followed only by whitespace until the end of the line. While syntactically valid, using /* ... */ for such cases can be less clear, potentially misleading developers into thinking it’s part of a larger multi-line comment block.
How to remediate
To fix this, replace the single-line block comment with an end-of-line comment. For example, change /* Some comment */ to // Some comment. This improves code readability and aligns with common Kotlin style guidelines where // is used for concise, single-line explanations and /* */ is reserved for multi-line documentation or temporarily disabling code blocks.
Non-Compliant Code Examples
/* Some comment */valfoo="foo"/* Some comment */
Compliant Code Examples
/*
* Some comment
*/valfoo="foo"// Some comment
valfoo={/* no-op */}/** Documentation */valfoo="foo"
シームレスな統合。 Datadog Code Security をお試しください
Datadog Code Security
このルールを試し、Datadog Code Security でコードを解析する
このルールの使用方法
1
2
rulesets:- kotlin-code-style # Rules to enforce Kotlin code style.