Annotated declarations should be visually separated
ID: kotlin-code-style/annotation-blank-line
Language: Kotlin
Severity: Notice
Category: Code Style
Description
When defining functions with annotations, separating them with a blank line provides more visual clarity.
Non-Compliant Code Examples
// Functions
fun parse() {}
@Benchmark
fun process() {
}
// Classes
annotation class Foo
@MustBeDocumented
@Repeatable
annotation class Bar
annotation class Foo
@MustBeDocumented
annotation class Bar(val info: String)
class Baz {
fun parse() {}
@Inject constructor() { }
}
fun parse() {}
@Entity
abstract class User {
}
fun parse() {}
@Entity
@Sample
class User {
fun foo()
}
fun parse() {}
@Entity
sealed class User {
}
fun parse() {}
@Deprecated
fun interface SomeInterface {
fun doSomething()
}
fun parse() {}
@Deprecated
interface Marker
fun parse() {}
@Deprecated
class Invalid : Exception()
fun parse() {}
@Deprecated
@Sample
abstract class Invalid: Exception()
Compliant Code Examples
// Functions
fun parse() {}
@Benchmark
fun process() {}
Seamless integrations. Try Datadog Code Security