Complexity Hotspot Remediation
Status: Requested
Repository: arda-frontend-app
Prerequisite: SonarJS Integration Phase 0 complete
Refactor the 5 highest-complexity files in arda-frontend-app to bring cognitive and cyclomatic complexity scores below the Phase 2 thresholds before the SonarJS ratcheting schedule tightens CI enforcement.
Hotspot Files
Section titled “Hotspot Files”| # | File | Cognitive max | Cyclomatic max | Priority | Approach |
|---|---|---|---|---|---|
| 1 | src/app/items/page.tsx | 111 | 81 | P1 | Component decomposition + extract business logic |
| 2 | src/app/order-queue/page.tsx | 89 | 94 | P1 | Component decomposition + extract state management |
| 3 | src/components/scan/MobileScanView.tsx | ~40 | ~40 | P2 | Extract scan-step sub-components |
| 4 | src/components/items/ItemFormPanel.tsx | ~30 | ~30 | P2 | Extract form sections + simplify validation branching |
| 5 | src/components/table/columnPresets.tsx | ~25 | ~25 | P3 | Extract column factory helpers |
Acceptance Criteria
Section titled “Acceptance Criteria”For each hotspot file:
- No function with cognitive complexity > 20 or cyclomatic complexity > 15.
- All existing tests pass after refactoring.
- No new
eslint-disablecomments for complexity rules. - PR description includes before/after complexity scores.
Refactoring Principles
Section titled “Refactoring Principles”- Preserve behavior: Every refactoring must be covered by existing tests. Add tests before refactoring if coverage is insufficient.
- Decompose, do not rewrite: Extract sub-components and helper functions from existing code. Avoid architectural changes that alter data flow.
- One file per PR: Each hotspot gets its own PR for reviewability.
- Measure before and after: Run
make complexityand include scores in the PR description.
Estimation
Section titled “Estimation”- P1 files (items page, order-queue page): 2-3 days each. Largest and most complex; component decomposition requires design decisions.
- P2 files (MobileScanView, ItemFormPanel): 1 day each.
- P3 file (columnPresets): 0.5 days.
- Total: 7-9 days of focused refactoring work.
Agent teams can execute the mechanical refactoring under human-approved decomposition plans.
Scheduling
Section titled “Scheduling”Address P1 files before SonarJS Phase 2 enforcement begins (approximately Month 2 of the SonarJS rollout). P2/P3 files can follow in subsequent sprints.
Copyright: © Arda Systems 2025-2026, All rights reserved