Shared logic is extracted into reusable modules
Why it matters
Duplicated logic is a maintenance trap: every bug fix, every business rule change, and every refactor must happen in N places simultaneously. Miss one copy and you ship an inconsistency. ISO 25010 maintainability.reusability directly penalizes this pattern. AI-generated codebases accumulate duplicate logic across sessions because the model rewrites familiar patterns rather than importing the utility it generated three sessions ago. Date formatting, currency conversion, and API error handling are the most common duplicated patterns.
Severity rationale
Medium because duplicated logic creates divergence risk on every future change, but individual copies typically function correctly in isolation until they get out of sync.
Remediation
Extract duplicated utility logic into a shared module and replace each copy with the import:
// lib/utils/format.ts
export function formatCurrency(amount: number, currency = 'USD'): string {
return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount)
}
export function formatRelativeDate(date: Date): string {
// single implementation, used everywhere
}
Your IDE's "Extract to function" refactor handles the initial extraction. After centralizing, run a search for the old inline pattern to confirm all copies are replaced.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Code Maintainability Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · maintainability.reusability — Reusability
- iso-25010:2011 · maintainability.modularity — Modularity
Taxons
History
- 2026-04-18·v1.0.0·Initial import from code-maintainability·automated