Skip to content

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.

#FileCognitive maxCyclomatic maxPriorityApproach
1src/app/items/page.tsx11181P1Component decomposition + extract business logic
2src/app/order-queue/page.tsx8994P1Component decomposition + extract state management
3src/components/scan/MobileScanView.tsx~40~40P2Extract scan-step sub-components
4src/components/items/ItemFormPanel.tsx~30~30P2Extract form sections + simplify validation branching
5src/components/table/columnPresets.tsx~25~25P3Extract column factory helpers

For each hotspot file:

  • No function with cognitive complexity > 20 or cyclomatic complexity > 15.
  • All existing tests pass after refactoring.
  • No new eslint-disable comments for complexity rules.
  • PR description includes before/after complexity scores.
  • 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 complexity and include scores in the PR description.
  • 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.

Address P1 files before SonarJS Phase 2 enforcement begins (approximately Month 2 of the SonarJS rollout). P2/P3 files can follow in subsequent sprints.