Skip to content

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

  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 BOOL_COMPARE

" SAP CI_ prefix format:
... "#EC CI_BOOL_COMPARE

Technical Details ​

Released under the MIT License.