This product is not supported for your selected Datadog site. ().
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/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

Integraciones sin problemas. Prueba Datadog Code Security