Avoid Negated IF Conditions with ELSE
WarningClean ABAP & Modern Syntax#EC NO_NEG_CONDRemote Enabled
Overview
Avoid negated IF conditions with ELSE.
ATC Finding Message:
Invert the condition and swap the branches
Rationale
A negated condition with an ELSE branch forces readers to negate the expression mentally before understanding the main path. Invert the condition and swap the branches, so the positive case comes first. This rule ignores ELSEIF chains and IS NOT predicates handled by the dedicated rule.
Non-Compliant
abap
IF NOT lv_is_valid.
handle_error( ).
ELSE.
process( ).
ENDIF.Compliant
abap
IF lv_is_valid.
process( ).
ELSE.
handle_error( ).
ENDIF.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_NEG_COND
" SAP CI_ prefix format:
... "#EC CI_NO_NEG_CONDTechnical Details
- Native ATC Class:
ZCL_SKYLINT_NO_NEG_COND - Implementation File: zcl_skylint_no_neg_cond.clas.abap