이 제품은 선택한 Datadog 사이트에서 지원되지 않습니다. ().
이 페이지는 아직 한국어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

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

원활한 통합. Datadog Code Security 사용해 보기