Shared Utils Audit
Overview
Run a repeatable audit that flags analysis components likely duplicating shared utility logic, then guide replacement with the canonical helpers.
Quick Start
Run the audit script and review findings:
bash
python3 .github/skills/shared-utils-audit/scripts/audit_shared_utils.py
Workflow
- •Run the audit against the analysis components (default target:
embuild-analyses/src/components/analyses). - •Review each finding and decide whether to replace custom logic with a shared helper.
- •Refactor the component or move novel logic into
embuild-analyses/src/libif it should become shared. - •Re-run the audit after refactors to confirm findings are resolved.
What The Script Flags
The audit uses regex heuristics and may produce false positives. It only flags patterns; confirm intent before changing code.
- •path-utils:
window.location.pathname,NEXT_PUBLIC_BASE_PATH, or'/data-blog'without@/lib/path-utilsimport. - •nis-fusion-utils:
padStart(5, "0")without@/lib/nis-fusion-utilsimport. - •geo-utils: manual arrondissement/province maps (
new Map(ARRONDISSEMENTS|PROVINCES)orprovinceByArrondissement/regionByProvince), even ifgeo-utilsis imported. - •press-utils:
Intl.DateTimeFormat("nl-BE")without@/lib/press-utilsimport.
Manual Checks (Not Covered By Script)
- •map-utils: look for hand-rolled municipality-to-arrondissement aggregation or region/province expansion that should use
aggregateMunicipalityToArrondissementorexpandGeoToMunicipalities. - •name-utils: look for custom municipality name casing logic that should use
formatMunicipalityName.
Script Options
bash
python3 .github/skills/shared-utils-audit/scripts/audit_shared_utils.py \ --target embuild-analyses/src/components/analyses \ --format json \ --max-matches 3
Run the built-in self-test:
bash
python3 .github/skills/shared-utils-audit/scripts/audit_shared_utils.py --self-test
Output Interpretation
Each file with findings lists the imported shared utils, the rule id/description, and matching lines with line numbers. Use the rule id to locate the intended shared helper in embuild-analyses/src/lib.