This product is not supported for your selected Datadog site. ().
이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

Metadata

ID: apex-code-style/self-assign

Language: Apex

Severity: Info

Category: Best Practices

Description

This rule detects assignments where a variable is assigned to itself, such as foo = foo;. Such statements are redundant and have no effect on the program’s state. They can indicate a mistake or misunderstanding in the code logic.

To comply with this rule, review assignments and ensure that each variable is assigned a meaningful or updated value. If the intent is to update a variable, use expressions that modify or transform its value, for example, foo = foo + 1;. If you are performing self-assignment to avoid leaving a parameter unused, you should be more explicit and assign it to a new variable, for example String ignore = unusedParameter.

Non-Compliant Code Examples

class Class {
    public void myFunction(){
        Integer foo;
        foo = foo;
    }
}

Compliant Code Examples

class Class {
    public void myFunction(){
        Integer foo;
        foo = foo + 1;
    }
}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

원활한 통합. Datadog Code Security를 경험해 보세요