Avoid Assignments Whose Value Is Never Read
WarningAnti-Patterns & Bad Practices#EC NO_DEAD_STORERemote Enabled
Overview
Avoid assignments that are never read.
ATC Finding Message:
This value is overwritten before it is read; remove the assignment or read it
Rationale
An assignment whose value is overwritten before any read computes a result nobody uses: the work, the helper call, and the temporary state are all wasted. Such dead stores usually survive a refactor that removed the consuming branch, and they mislead readers into believing the value matters. Either read the value or delete the assignment.
Non-Compliant
abap
lv_status = 'NEW'.
lv_status = 'DONE'.
WRITE lv_status.Compliant
abap
lv_status = 'DONE'.
WRITE lv_status.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_DEAD_STORE
" SAP CI_ prefix format:
... "#EC CI_NO_DEAD_STORERelated Rules
- Eliminate Unused Local Variables and Symbols —
#EC NO_UNUSED_VARS - Avoid Dead Code with Constant Conditions —
#EC NO_DEAD_CODE - Prefer FINAL( ) over DATA( ) when the variable is never written again —
#EC PREF_FINAL_DATA
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_DEAD_STORE - Implementation File: zcl_skylint_no_dead_store.clas.abap