Este producto no es compatible con el sitio Datadog seleccionado. ().
Esta página aún no está disponible en español. Estamos trabajando en su traducción.
Si tienes alguna pregunta o comentario sobre nuestro actual proyecto de traducción, no dudes en ponerte en contacto con nosotros.

Metadata

ID: swift-code-style/increment-decrement-single-stmt

Language: Unknown

Severity: Notice

Category: Best Practices

Description

Increments (++) or decrements (--) should be single statements. This rule is important because it helps to avoid confusion and potential errors in your code. When increments or decrements are combined with other operations, it can be difficult to understand the order in which the operations are performed. This can lead to unexpected results and bugs in your code.

Non-Compliant Code Examples

foo = ++bar - baz--
foo = bar++

foo(bar++)

Compliant Code Examples

++foo
bar++
--foo
func factorial(_ n: Int) -> Int {
    guard n >= 0 else {
        foo++
    }
    --bar
    return n == 0 ? 1 : n * factorial(n - 1)
}
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