Skip to content

refactor: consolidate duplicated helpers found in code-quality audit#11

Merged
Flowm merged 5 commits into
mainfrom
claude/elegant-feistel-a5c0c5
Jun 26, 2026
Merged

refactor: consolidate duplicated helpers found in code-quality audit#11
Flowm merged 5 commits into
mainfrom
claude/elegant-feistel-a5c0c5

Conversation

@Flowm

@Flowm Flowm commented Jun 26, 2026

Copy link
Copy Markdown
Owner

What

A strict whole-codebase code-quality audit found no structural issues — the architecture (shared aggregateVariables pipeline, single HourlySeries chart contract, framework-free analysis layer, clean layering) is already in good shape, and no file approaches 1000 lines. The audit surfaced only a handful of verbatim duplications, which this PR consolidates. Every change is behaviour-preserving.

Finding Change
runKey defined identically in two files Export it from sampleStore (which already owns mergeRuns), import in learnedWeights
HOURS_PER_DAY defined 3× Import the one already exported from verification.ts (drop locals in scorecard.ts + ModelScorecard.vue)
"Name, Detail" join reimplemented in all 3 views Add label to useLocation (+ a pure locationLabel() helper); views read it
clamp01 defined in two domain files Extract to a small domain/num.ts
Repeated VERIFY_VARS literal in evaluateRun Hoist to one module-level const

Why

These are canonical-home / DRY consolidations: a single concept that was living in two or three places now lives in one. No new abstraction layers — each helper moves to the module that already owns the concept.

Notes for reviewers

  • No behaviour change. useLocation.label emits a byte-identical string to the old per-view computed; the rest are pure symbol-sourcing moves.
  • Each commit was gated by the full pre-commit suite (oxlint + oxfmt + vue-tsc + vitest) — all green.
  • Deliberately not done: over-DRYing the scattered one-line stat/format helpers (mean, meanFinite, rankKey, per-component formatters) — they differ subtly and read more clearly co-located.

🤖 Generated with Claude Code

Flowm added 5 commits June 26, 2026 03:31
Export runKey from sampleStore (it already owns mergeRuns, which uses it)
and import it in learnedWeights instead of redefining the identical run-
identity helper. No behaviour change.

Assisted-by: ClaudeCode:claude-opus-4-8
verification.ts already exports HOURS_PER_DAY; scorecard.ts and
ModelScorecard.vue each redefined the same `= 24` local. Import the
shared constant instead. No behaviour change.

Assisted-by: ClaudeCode:claude-opus-4-8
The "Name, Detail" join was reimplemented as an identical computed in all
three views (forecast / verify / training). Move it to useLocation as a
`label` computed (plus a pure `locationLabel(loc)` helper) — the layer that
owns the location concept — and have the views read it. No behaviour change.

Assisted-by: ClaudeCode:claude-opus-4-8
predictability.ts and scorecard.ts each defined the identical clamp01.
Extract it to a small domain/num module and import from both. No
behaviour change.

Assisted-by: ClaudeCode:claude-opus-4-8
evaluateRun built the same temperature+precipitation VarSpec array inline
for both the default and tuned aggregation passes. Hoist it to a single
module-level const. No behaviour change.

Assisted-by: ClaudeCode:claude-opus-4-8
@github-actions

Copy link
Copy Markdown

⛅ Preview deployment

This PR is live at https://preview-a0d590dd-meteocompare.frcy.workers.dev

Commit a0d590dd — reproduce locally with npm run deploy:preview.

@Flowm
Flowm merged commit 4daa441 into main Jun 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant