Omit Unnecessary RETURN Statement
WarningAnti-Patterns & Bad PracticesQuickFix Ready#EC NO_UNNEC_RETURNRemote Enabled
Overview
Omit unnecessary RETURN at end of routine.
ATC Finding Message:
Omit optional RETURN at end of routine; routines return automatically
Rationale
A RETURN as the final statement of a method, form, or function changes nothing because the routine ends at ENDMETHOD, ENDFORM, or ENDFUNCTION anyway. It adds a line that implies a special exit and can obscure the real control flow. Remove trailing RETURN statements and keep early returns only where they are meaningful.
Non-Compliant
abap
METHOD get_total.
rv_total = lv_subtotal + lv_tax.
RETURN.
ENDMETHOD.Compliant
abap
METHOD get_total.
rv_total = lv_subtotal + lv_tax.
ENDMETHOD.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 NO_UNNEC_RETURN
" SAP CI_ prefix format:
... "#EC CI_NO_UNNEC_RETURNRelated Rules
- Do Not Ignore Return Value of Functional Methods —
#EC NO_IGNORED_RETURN - Prefer RETURN over EXIT in Methods —
#EC PREF_RETURN - Omit Redundant EXPORTING in Method Calls —
#EC NO_CALL_EXPORTING
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_UNNEC_RETURN - Implementation File: zcl_skylint_no_unnec_return.clas.abap