Do Not CLEAR Variables Directly After Declaration
WarningAnti-Patterns & Bad PracticesQuickFix Ready#EC REDUNDANT_CLEARRemote Enabled
Overview
Do not CLEAR or FREE variables redundantly.
ATC Finding Messages:
Do not CLEAR or FREE variables after declaration; they are already initialVariable is CLEARed or FREEd but never read again before procedure ends
Rationale
A newly declared variable already has its type-specific initial value, so CLEAR immediately after DATA is a no-op. It adds noise and suggests the declaration might not initialize the variable. Remove the CLEAR or initialize the variable when it is actually reused.
Non-Compliant
abap
DATA lt_items TYPE string_table.
CLEAR lt_items.Compliant
abap
DATA lt_items TYPE string_table.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.
Configuration & Thresholds
This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:
| Parameter Name | Data Type | Default Value |
|---|---|---|
CHECK_BEFORE_WRITE | Boolean | true |
CHECK_WITHOUT_READ | Boolean | true |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC REDUNDANT_CLEAR
" SAP CI_ prefix format:
... "#EC CI_REDUNDANT_CLEARTechnical Details
- Native ATC Class:
ZCL_SKYLINT_NO_REDUNDANT_CLEAR - Implementation File: zcl_skylint_no_redundant_clear.clas.abap