Limit Cyclomatic Complexity
WarningMetrics & Complexity Limits#EC CYCLO_COMPRemote Enabled
Overview
Cyclomatic Complexity Threshold.
ATC Finding Message:
Procedure cyclomatic complexity exceeds threshold
Rationale
Cyclomatic complexity counts the independent decision paths through a method, so a high value means many branches need separate tests. Such methods are hard to understand and easy to break when one condition changes. Split the decisions into cohesive helper methods or strategy objects.
Non-Compliant
abap
METHOD check_order.
IF is_blocked( ).
RETURN.
ENDIF.
IF has_no_stock( ).
RETURN.
ENDIF.
IF is_over_limit( ).
RETURN.
ENDIF.
IF needs_approval( ).
approve( ).
ENDIF.
IF is_priority( ).
expedite( ).
ENDIF.
release( ).
ENDMETHOD.Compliant
abap
METHOD check_order.
validate_order( ).
approve_order( ).
release_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_COMPLEXITY | Integer | 5 |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC CYCLO_COMP
" SAP CI_ prefix format:
... "#EC CI_CYCLO_COMPTechnical Details
- Native ATC Class:
ZCL_SKYLINT_MAX_CYCLO_COMP - Implementation File: zcl_skylint_max_cyclo_comp.clas.abap