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 Name | Data Type | Default Value |
|---|---|---|
MAX_STATEMENTS | Integer | 5 |
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_LENTechnical Details
- Native ATC Class:
ZCL_SKYLINT_MAX_METHOD_LEN - Implementation File: zcl_skylint_max_method_len.clas.abap