Prefer IS [NOT] INITIAL over lines( ) or Literal Comparisons
WarningClean ABAP & Modern SyntaxQuickFix Ready#EC PREF_INITRemote Enabled
Overview
Prefer IS [NOT] INITIAL over lines( ) or empty literals.
ATC Finding Message:
Use IS [NOT] INITIAL instead of lines( ) or empty literal comparison
Rationale
Comparing lines( ) to zero or a string to an empty literal asks an indirect question. IS INITIAL states emptiness directly and works for tables, strings, structures, and elementary values. It also avoids counting overhead and literal edge cases.
Non-Compliant
abap
IF lines( lt_items ) > 0.
process( ).
ENDIF.Compliant
abap
IF lt_items IS NOT INITIAL.
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 PREF_INIT
" SAP CI_ prefix format:
... "#EC CI_PREF_INITTechnical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_IS_INITIAL - Implementation File: zcl_skylint_pref_is_initial.clas.abap