Over-engineering / DRY (ponytail-audit finding)
clamp(value, min, max) has an identical body — Math.min(max, Math.max(min, value)) — copy-pasted across four modules, plus two more inline variants.
Duplicated in
src/utils/testCalc.ts
src/pages/TestResultsPage.tsx
src/utils/placementRouting.ts
src/utils/testSummaryAggregator.ts
- inline variants:
src/pages/GradeStudent.tsx (line 73), src/pages/TestBuilderPage.tsx (clampThresholdPct, line 39)
Fix
Add src/utils/clamp.ts with a single exported clamp, import it in the four files, and drop the local copies. Fold the two inline variants in where they match. Net ~-18 lines.
Scope: complexity cleanup only, not a bug.
Over-engineering / DRY (ponytail-audit finding)
clamp(value, min, max)has an identical body —Math.min(max, Math.max(min, value))— copy-pasted across four modules, plus two more inline variants.Duplicated in
src/utils/testCalc.tssrc/pages/TestResultsPage.tsxsrc/utils/placementRouting.tssrc/utils/testSummaryAggregator.tssrc/pages/GradeStudent.tsx(line 73),src/pages/TestBuilderPage.tsx(clampThresholdPct, line 39)Fix
Add
src/utils/clamp.tswith a single exportedclamp, import it in the four files, and drop the local copies. Fold the two inline variants in where they match. Net ~-18 lines.Scope: complexity cleanup only, not a bug.