refactor: consolidate duplicated helpers found in code-quality audit#11
Merged
Conversation
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
⛅ Preview deploymentThis PR is live at https://preview-a0d590dd-meteocompare.frcy.workers.dev Commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A strict whole-codebase code-quality audit found no structural issues — the architecture (shared
aggregateVariablespipeline, singleHourlySerieschart 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.runKeydefined identically in two filessampleStore(which already ownsmergeRuns), import inlearnedWeightsHOURS_PER_DAYdefined 3×verification.ts(drop locals inscorecard.ts+ModelScorecard.vue)"Name, Detail"join reimplemented in all 3 viewslabeltouseLocation(+ a purelocationLabel()helper); views read itclamp01defined in two domain filesdomain/num.tsVERIFY_VARSliteral inevaluateRunWhy
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
useLocation.labelemits a byte-identical string to the old per-view computed; the rest are pure symbol-sourcing moves.mean,meanFinite,rankKey, per-component formatters) — they differ subtly and read more clearly co-located.🤖 Generated with Claude Code