Avoid Local Variables Shadowing Class Attributes
WarningAnti-Patterns & Bad Practices#EC NO_SHADOWLocal Only
Overview
Avoid local variables shadowing class attributes.
ATC Finding Message:
Local variable shadows a class attribute; rename it
Rationale
A local variable that repeats a class attribute name silently hides the member inside the method. Readers can no longer tell whether the code changes the object state or only a temporary copy, and a later refactoring may keep the wrong reference. Rename the local or use a distinct name that states its purpose.
Non-Compliant
abap
DATA mv_status TYPE string.
mv_status = 'OPEN'.Compliant
abap
DATA lv_status TYPE string.
lv_status = 'OPEN'.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_SHADOW
" SAP CI_ prefix format:
... "#EC CI_NO_SHADOWTechnical Details
- Native ATC Class:
ZCL_SKYLINT_NO_SHADOW - Implementation File: zcl_skylint_no_shadow.clas.abap