Skip to content

Limit Multiple Return Statements per Method Body ​

WarningMetrics & Complexity Limits#EC MAX_RETURNSRemote Enabled

Overview ​

Limit number of RETURN statements (PLR0911).

ATC Finding Message: Method has too many RETURN statements; consider refactoring

Rationale ​

While early return guard clauses at the top of a method are encouraged by Clean ABAP, scattering a dozen RETURN or EXIT statements throughout the middle and end of a long procedure makes control flow unpredictable. It becomes difficult to ensure that cleanup logic or post-conditions are reliably reached.

Clean ABAP Guideline: Use early returns strictly for parameter and state validation guards at the entry point of the method. Keep the core execution flow to a single, predictable exit point.

Non-Compliant ​

abap
" Anti-pattern: 8 scattered return points throughout 100 lines of logic
METHOD calculate_tax.
  ...
  IF condition_a. RETURN. ENDIF.
  ...
  IF condition_b. RETURN. ENDIF.
  ...
  IF condition_c. RETURN. ENDIF.
  ...
ENDMETHOD.

Compliant ​

abap
" Clean ABAP: Grouped guard clauses at top, single deterministic computation exit
METHOD calculate_tax.
  IF is_tax_exempt( is_customer ).
    rv_tax = 0.
    RETURN.
  ENDIF.

  rv_tax = compute_standard_rate( is_customer ).
ENDMETHOD.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault ValueDescription & Guidance
MAX_RETURNSInteger6Maximum allowed total return points (RETURN, EXIT) within a single method

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC MAX_RETURNS

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

Technical Details ​

Released under the MIT License.