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/max-line-len

Language: Kotlin

Severity: Notice

Category: Code Style

Description

This rule ensures that no line in your Kotlin code exceeds a certain maximum length, set to 140 characters by default. Exceeding this limit can lead to code that is difficult to read and understand, especially when working with complex codebases or reviewing code changes. It can also cause issues with version control systems that have difficulty handling long lines.

The rule take the argument max-line-length to adapt its behavior with your coding style and guidelines.

Non-Compliant Code Examples

val fooooooooooooooo = "fooooooooooooooooooooo"
val foo = "foo" + "ooooooooooooooooooooooooooo"
val foooooooooooooo = "foooooooooooooooooooo" // some comment
val bad = "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
val foooooooooooooo = "foooooooooooooooooooo"                                                                                             // some comment
foo(bar,                       baz, bli, blo, foooooooooooooooooooo, foooooooooooooooooooo2, foooooooooooooooooooo3, foooooooooooooooooooo43)

Compliant Code Examples

package com.datadog.client.model.ucap

import com.datadog.intellij.toolkit.serialization.InstantISO8601Serializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import java.time.Instant

@Serializable
@JvmInline
value class ActionId(val value: String)

@Serializable
class Action(val id: ActionId, val attributes: ActionAttributes)

@Serializable
data class ActionAttributes(
    val name: String,
    val description: String?,
    val detail: String?,
    @Serializable(with = InstantISO8601Serializer::class) val timestamp: Instant,
    @SerialName("annotation_id") val annotationId: AnnotationId,
    @SerialName("action_key") val actionKey: String,
    val status: Status,
    val recomputable: Boolean,
    val recommendation: String?,
    val modification: Modification?,
) {
    enum class Status {
        GENERATING,
        READY,
        FAILED
    }

    @Serializable
    data class Modification(
        @SerialName("repository_url") val repositoryUrl: String,
        @SerialName("commit_sha") val commitSha: String,
        val patch: String
    )
}
val fooooooooooooooo = "fooooooooooooooooooooo"
val foo = "foo" + "ooooooooooooooooooooooooooo"
val foooooooooooooo = "foooooooooooooooooooo" // some comment
foo(bar)
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