Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

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

Seamless integrations. Try Datadog Code Security

PREVIEWING: guacbot/translation-pipeline