Skip to content

Limit Jump Statements (CONTINUE, EXIT) per Loop ​

WarningMetrics & Complexity Limits#EC MAX_LOOP_JUMPSRemote Enabled

Overview ​

Limit jump statements (CONTINUE/EXIT) per loop.

ATC Finding Message: Loop has too many jump statements (CONTINUE/EXIT); simplify loop control flow

Rationale ​

Loops containing too many jump statements (CONTINUE, EXIT) have convoluted control flow that makes loop invariants difficult to reason about and maintain. Restructure the loop body using helper methods or simplified boolean conditions.

Non-Compliant ​

abap
LOOP AT lt_items INTO ls_item.
  IF cond1. CONTINUE. ENDIF.
  IF cond2. EXIT. ENDIF.
  IF cond3. CONTINUE. ENDIF.
ENDLOOP.

Compliant ​

abap
LOOP AT lt_items INTO ls_item WHERE ...
  process_item( ls_item ).
ENDLOOP.

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_LOOP_JUMPSInteger2Maximum number of jump statements (CONTINUE/EXIT) allowed per loop (default: 2)

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.