Skip to content

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):

  1. Position the cursor on the flagged statement.
  2. Press Ctrl + 1 (Quick Assist).
  3. 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_CODE

Technical Details ​

Released under the MIT License.