Prefer RETURN over EXIT in Methods
WarningClean ABAP & Modern SyntaxQuickFix Ready#EC RETURNRemote Enabled
Overview
Prefer RETURN over EXIT outside loop constructs.
ATC Finding Message:
Use RETURN instead of EXIT when leaving a procedure
Rationale
EXIT has loop-specific meaning and can leave a method at a point that is easy to overlook when the surrounding code changes. RETURN explicitly ends the current procedure and cannot be confused with loop control. Use RETURN for method exit and LEAVE LOOP or CONTINUE for loop control.
Non-Compliant
abap
IF is_invalid( ).
EXIT.
ENDIF.
process( ).Compliant
abap
IF is_invalid( ).
RETURN.
ENDIF.
process( ).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 RETURN
" SAP CI_ prefix format:
... "#EC CI_RETURNTechnical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_RETURN - Implementation File: zcl_skylint_pref_return.clas.abap