Merge Nested IF Statements
WarningClean ABAP & Modern SyntaxQuickFix Ready#EC MERGE_IFSRemote Enabled
Overview
Merge consecutive nested IF blocks using boolean AND.
ATC Finding Messages:
Nested IF block can be merged with outer IF using ANDNested IF in ELSE block can be changed to ELSEIF
Rationale
Nested IF statements without intermediate statements add indentation without adding meaning. Merging them with AND or converting a nested IF in an ELSE block into ELSEIF flattens the control flow and makes the combined condition explicit. Less nesting reduces cyclomatic complexity and makes the happy path easier to test.
Non-Compliant
abap
IF is_active( ).
IF is_authorized( ).
process_order( ).
ENDIF.
ENDIF.Compliant
abap
IF is_active( ) AND is_authorized( ).
process_order( ).
ENDIF.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 MERGE_IFS
" SAP CI_ prefix format:
... "#EC CI_MERGE_IFSTechnical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_MERGE_IFS - Implementation File: zcl_skylint_pref_merge_ifs.clas.abap