Avoid Comparing to abap_true / abap_false
WarningAnti-Patterns & Bad PracticesQuickFix Ready#EC BOOL_COMPARERemote Enabled
Overview
Avoid comparing boolean method calls to boolean literals.
ATC Finding Message:
Avoid boolean comparison for method calls; call method directly
Rationale
A boolean expression already evaluates to true or false, so comparing it to abap_true is redundant. The comparison hides predicate intent and can mask a missing method call or an accidental assignment. Test the expression directly and use NOT when the negative case is needed.
Non-Compliant
abap
IF is_valid( ) = abap_false.
RETURN.
ENDIF.Compliant
abap
IF NOT is_valid( ).
RETURN.
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 BOOL_COMPARE
" SAP CI_ prefix format:
... "#EC CI_BOOL_COMPARETechnical Details
- Native ATC Class:
ZCL_SKYLINT_NO_BOOL_COMPARE - Implementation File: zcl_skylint_no_bool_compare.clas.abap