Eliminate Unused Local Variables and Symbols
WarningAnti-Patterns & Bad Practices#EC NO_UNUSED_VARSRemote Enabled
Overview
Detect unused local variables and field symbols.
ATC Finding Message:
Local variable or field symbol is declared but never read
Rationale
An unused variable or field symbol adds noise and suggests incomplete refactoring or a missing assignment. It keeps dead objects alive longer than necessary and makes reviews harder. Remove the declaration, or mark it with ##NEEDED when an external contract requires it.
Non-Compliant
abap
DATA lv_message TYPE string.
process_order( ).Compliant
abap
DATA lv_message TYPE string.
lv_message = |Order { lv_id }|.
log_message( lv_message ).Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_UNUSED_VARS
" SAP CI_ prefix format:
... "#EC CI_NO_UNUSED_VARSRelated Rules
- Enforce Local Variable and Field-Symbol Naming Conventions —
#EC PREF_NAMING_VARS - Avoid Local Variables Shadowing Class Attributes —
#EC NO_SHADOW - Require Fully Typed Variables and Parameters —
#EC PREF_FULL_TYPED
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_UNUSED_VARS - Implementation File: zcl_skylint_no_unused_vars.clas.abap