# Complexity Analysis

> [← Back to README](../README.md) | [Code Metrics](./code-metrics.md) | [Dependency Analysis →](./dependency-analysis.md)

## Conditional Branch Counts (Base Programs)

| Program | LOC | IF Stmts | EVALUATE | PERFORM | GO TO | Complexity |
|:--------|----:|--------:|---------:|--------:|------:|:-----------|
| COACTUPC | 4,236 | 168 | 20 | 64 | 51 | 🔴 Very High |
| COCRDUPC | 1,560 | 148 | 16 | 26 | 21 | 🔴 Very High |
| COCRDLIC | 1,459 | 122 | 18 | 34 | 16 | 🔴 High |
| CBTRN02C | 731 | 93 | 0 | 62 | 0 | 🟡 High |
| CBACT04C | 652 | 86 | 0 | 57 | 0 | 🟡 High |
| CBTRN03C | 649 | 75 | 4 | 73 | 0 | 🟡 High |
| COCRDSLC | 887 | 68 | 8 | 19 | 9 | 🟡 Medium-High |
| COACTVWC | 941 | 57 | 10 | 21 | 9 | 🟡 Medium-High |
| CBTRN01C | 494 | 33 | 0 | 43 | 0 | 🟢 Medium |
| COTRN00C | 699 | 26 | 16 | 47 | 0 | 🟢 Medium |
| COUSR00C | 695 | 25 | 16 | 45 | 0 | 🟢 Medium |
| CBACT01C | 430 | 22 | 0 | 36 | 0 | 🟢 Medium |
| CORPT00C | 649 | 20 | 10 | 35 | 1 | 🟢 Medium |
| CBSTM03A | 924 | 15 | 9 | 33 | 15 | 🟡 Medium |
| CBEXPORT | 582 | 16 | 0 | 50 | 0 | 🟢 Medium |
| COTRN02C | 783 | 14 | 26 | 61 | 0 | 🟢 Medium |
| CBIMPORT | 487 | 14 | 2 | 30 | 0 | 🟢 Low-Medium |
| COUSR02C | 414 | 13 | 10 | 31 | 0 | 🟢 Low |
| CBSTM03B | 230 | 12 | 1 | 4 | 13 | 🟡 Medium (GO TO) |
| COBIL00C | 572 | 10 | 18 | 38 | 0 | 🟢 Low |
| COADM01C | 288 | 11 | 4 | 15 | 0 | 🟢 Low |
| COUSR03C | 359 | 8 | 10 | 26 | 0 | 🟢 Low |
| COMEN01C | 308 | 7 | 6 | 15 | 0 | 🟢 Low |
| COTRN01C | 330 | 7 | 6 | 17 | 0 | 🟢 Low |
| COUSR01C | 299 | 4 | 6 | 20 | 0 | 🟢 Low |
| COSGN00C | 260 | 4 | 6 | 11 | 0 | 🟢 Low |

## Top Complexity Concerns

### 1. COACTUPC (4,236 lines) — 🔴 Critical
- 168 IF statements, 20 EVALUATE blocks, 51 GO TO statements
- 18+ COPY CSSETATY REPLACING instances for field attribute management
- Deeply nested validation logic for account fields
- Largest program in the entire application

### 2. COCRDUPC (1,560 lines) — 🔴 High
- 148 IF statements, 21 GO TO statements
- Complex card update validation logic
- Date editing with CSUTLDWY/CSUTLDPY

### 3. COCRDLIC (1,459 lines) — 🔴 High
- 122 IF statements, 16 GO TO statements
- Complex pagination and browse logic

### 4. GO TO Usage
Programs with GO TO statements indicate less structured code:
- COACTUPC: 51 GO TO statements
- COCRDUPC: 21 GO TO statements
- COCRDLIC: 16 GO TO statements
- CBSTM03A: 15 GO TO statements
- CBSTM03B: 13 GO TO statements
- COACTVWC: 9 GO TO statements
- COCRDSLC: 9 GO TO statements
- CORPT00C: 1 GO TO statement

**Total:** 8 programs use GO TO (out of 31 base programs = 26%)

## COPY REPLACING Complexity

COACTUPC uses `COPY CSSETATY REPLACING` 18+ times (lines 3208-3310) to set field attributes — a pattern that significantly inflates the effective code size after preprocessing.

---

*See also: [Code Metrics](./code-metrics.md) | [Dependency Analysis](./dependency-analysis.md) | [Technical Debt](../technical-debt/maintenance-burden.md)*
