Skip to content

Limit Method Length (Statements) ​

WarningMetrics & Complexity Limits#EC METHOD_LENRemote Enabled

Overview ​

Method Length Limit (excessive statement count).

ATC Finding Message: Method length exceeds maximum allowed statement limit

Rationale ​

A method with many statements usually carries several responsibilities and accumulates local state that is hard to follow. Long methods are difficult to unit test, review, and reuse, and they tend to change for unrelated reasons. Extract cohesive steps into small named methods so each one has a single purpose.

Non-Compliant ​

abap
METHOD post_order.
  DATA lv_total TYPE i.
  lv_total = ls_order-quantity * ls_order-price.
  check_credit( ls_order-customer_id ).
  save_header( ls_order ).
  save_items( ls_order ).
  update_status( ls_order ).
  log_created( ls_order ).
ENDMETHOD.

Compliant ​

abap
METHOD post_order.
  prepare_order( ls_order ).
  save_order( ls_order ).
  log_created( ls_order ).
ENDMETHOD.

Configuration & Thresholds ​

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

Parameter NameData TypeDefault Value
MAX_STATEMENTSInteger5

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.