Prefer FINAL( ) over DATA( ) when the variable is never written again
WarningClean ABAP & Modern SyntaxQuickFix Ready#EC PREF_FINALRemote Enabled
Overview
Declare inline variables as FINAL when never written again.
ATC Finding Message:
Inline variable is never written again; declare it with FINAL( )
Rationale
An inline variable that is assigned once and never changed should be declared FINAL so the compiler enforces immutability. This prevents accidental later writes and documents that the value is a constant for the rest of the method. Use FINAL( ) for single-assignment locals.
Non-Compliant
abap
DATA(lv_count) = lines( lt_items ).
process( lv_count ).Compliant
abap
FINAL(lv_count) = lines( lt_items ).
process( lv_count ).Automated QuickFix
This rule provides an automated QuickFix directly in Eclipse ABAP Development Tools (ADT):
- Position the cursor on the flagged statement.
- Press Ctrl + 1 (Quick Assist).
- Select the automated refactoring to apply the clean syntax immediately.
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_FINAL
" SAP CI_ prefix format:
... "#EC CI_PREF_FINALTechnical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_FINAL_DATA - Implementation File: zcl_skylint_pref_final_data.clas.abap