This page is not yet available in Spanish. We are working on its translation.
If you have any questions or feedback about our current translation project, feel free to reach out to us!

Metadata

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() {}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Integraciones sin problemas. Prueba Datadog Code Security

PREVIEWING: guillaume.barrier/ERRORT-5095-general-doc-update