Ce produit n'est pas pris en charge pour le site Datadog que vous avez sélectionné. ().
Cette page n'est pas encore disponible en français. Nous travaillons sur sa traduction.
Si vous avez des questions ou des commentaires concernant notre projet de traduction actuel, n'hésitez pas à nous contacter !

Metadata

ID: kotlin-code-style/function-type-modifier-spacing

Language: Kotlin

Severity: Notice

Category: Code Style

Description

There should be a single space for type modifiers for a function type and the parameters or receiver.

Non-Compliant Code Examples

// Function type
val process: suspend() -> Unit = {}

// Function type with receiver
val process: suspend   String.() -> Unit = { println(this) }

// Function type with nullable receiver
val process: suspend   String?.() -> Unit = { if (this != null) println(this) }

// Nullable function type
val process: (suspend() -> Unit)? = null

// Function type as parameter
suspend fun execute(task: suspend  () -> Unit) { task() }

Compliant Code Examples

// Function type
val process: suspend () -> Unit = {}

// Function type with receiver
val process: suspend String.() -> Unit = { println(this) }

// Function type with nullable receiver
val process: suspend String?.() -> Unit = { if (this != null) println(this) }

// Nullable function type
val process: (suspend () -> Unit)? = null

// Function type as parameter
suspend fun execute(task: suspend () -> Unit) { task() }
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Intégrations fluides. Essayez Datadog Code Security