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

Language: Kotlin

Severity: Notice

Category: Code Style

Description

Keeping the assignment operator on the same line as the value being assigned improves understandability of code.

Non-Compliant Code Examples

val concurrency // The number of coroutines to use
    = 6

fun sum(a: Int, b: Int): Int
    =      a + b

fun countFor(jobName: String?
= null): Int = 3

val (first, last)
    = getName()

class Router {
    val isEnabled get()
        = true
}

val generate: () -> String?
        // For now, just return null
        = { null }

Compliant Code Examples

val concurrency = // The number of coroutines to use
    6

fun sum(a: Int, b: Int): Int =
    a + b

fun countFor(jobName: String? =
null): Int = 3

val (first, last) =
    getName()

class Router {
    val isEnabled get() =
        true
}

val generate: () -> String? =
        // For now, just return null
        { null }

fun sum(a: Int, b: Int): Int = a + b
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: heston/DOCS-10466