Avoid Dead Code with Constant Conditions
WarningAnti-Patterns & Bad PracticesQuickFix Ready#EC NO_DEAD_CODERemote Enabled
Overview
Detect Dead Code with Constant Condition.
ATC Finding Message:
Condition is always false, creating dead code
Rationale
A condition that is always false, such as 1 = 2 or abap_false, makes the branch impossible to reach. Dead branches hide unfinished logic and can contain declarations that confuse scope analysis. Remove the branch or replace the constant with the real runtime condition.
Non-Compliant
abap
IF 1 = 2.
process( ).
ENDIF.Compliant
abap
IF is_enabled( ).
process( ).
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 NO_DEAD_CODE
" SAP CI_ prefix format:
... "#EC CI_NO_DEAD_CODETechnical Details
- Native ATC Class:
ZCL_SKYLINT_NO_DEAD_CODE - Implementation File: zcl_skylint_no_dead_code.clas.abap