Avoid Chained Assignments (a = b = c = 1)
WarningAnti-Patterns & Bad PracticesQuickFix Ready#EC NO_CHAINED_ASSIGNRemote Enabled
Overview
Avoid Chained Assignments.
ATC Finding Message:
Avoid chained assignments; write separate assignment statements
Rationale
Chained assignments evaluate right-to-left and bind multiple targets in a single statement, making code execution order difficult to follow and debug. Split chained assignments into distinct, explicit assignment statements.
Non-Compliant
abap
lv_a = lv_b = lv_c = 0.Compliant
abap
lv_c = 0.
lv_b = lv_c.
lv_a = lv_b.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 NO_CHAINED_ASSIGN
" SAP CI_ prefix format:
... "#EC CI_NO_CHAINED_ASSIGNRelated Rules
- Avoid Chained Declarations (DATA:, CONSTANTS:, TYPES:) —
#EC NO_CHAINED_DECL - Remove Redundant Self-Assignments and CLEAR Statements —
#EC SELF_ASSIGN - Eliminate Unused Local Variables and Symbols —
#EC NO_UNUSED_VARS
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_CHAINED_ASSIGN - Implementation File: zcl_skylint_no_chained_assign.clas.abap