Skip to content

Limit Cyclomatic Complexity (McCabe Complexity Metric) ​

WarningMetrics & Complexity Limits#EC MAX_CYCLO_COMPRemote Enabled

Overview ​

Cyclomatic Complexity Threshold.

ATC Finding Message: Procedure cyclomatic complexity exceeds threshold

Rationale ​

Cyclomatic Complexity measures the number of linearly independent paths through a procedure's source code (branch points like IF, ELSEIF, WHEN, WHILE, AND, OR, CATCH). High complexity correlates directly with high defect density, regression risks during refactoring, and poor unit test branch coverage.

Clean ABAP Guideline: Keep cyclomatic complexity under 10 (or maximum 15 for large state dispatches). Extract branches into polymorphically dispatched strategy classes or smaller helper methods.

Non-Compliant ​

abap
" Anti-pattern: Massive branching complexity score (>20) with nested conditionals
METHOD calculate_discount.
  IF iv_region = 'EU'.
    IF iv_cust_tier = 'VIP' AND iv_amount > 1000.
      rv_disc = 20.
    ELSEIF iv_cust_tier = 'GOLD' OR iv_amount > 500.
      rv_disc = 15.
    ...
  ENDIF.
ENDMETHOD.

Compliant ​

abap
" Clean ABAP: Delegate calculations to cohesive strategy pattern or rule table
METHOD calculate_discount.
  DATA(lo_strategy) = mo_discount_factory->get_strategy( iv_region ).
  rv_disc = lo_strategy->calculate( iv_tier = iv_cust_tier iv_amount = iv_amount ).
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_COMPLEXITYInteger5Maximum allowed cyclomatic complexity score per method (default threshold: 10)

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.