]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
refactor(charging-station): extract reservation helpers from Helpers.ts (issue #1936...
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 3 Jul 2026 19:53:26 +0000 (21:53 +0200)
committerGitHub <noreply@github.com>
Fri, 3 Jul 2026 19:53:26 +0000 (21:53 +0200)
commitf03e7f35b77d8d68523325982650d5cd749c2e89
tree2d0fe542df8c292c3a16bf76b9f398d1882bd523
parenta68ca80e2390476c8407ee0149b409e444d95bd5
refactor(charging-station): extract reservation helpers from Helpers.ts (issue #1936 f Phase 1) (#1946)

* refactor(charging-station): extract reservation helpers from Helpers.ts (issue #1936 f)

Phase 1 of the Helpers.ts file split tracked in issue #1936 item (f).

Helpers.ts is 1389 LOC — 5.5x the 250 LOC ceiling documented in
AGENTS.md's programming skill. This PR extracts the smallest cohesive
block (the 4 reservation helpers) into a dedicated file as an initial
step, proving the barrel-preservation pattern so the remaining slices
can follow in subsequent PRs without breaking any callers.

Extracted symbols into HelpersReservation.ts:
- hasReservationExpired
- hasPendingReservation
- hasPendingReservations
- removeExpiredReservations

Helpers.ts (1389 -> 1336 LOC) keeps the public API via a barrel
re-export block. Every external caller ('import { ... } from
"./Helpers.js"') continues to work unchanged. Now-unused imports
in Helpers.ts (isPast, Reservation, ReservationTerminationReason)
are dropped.

Test invariant fail: 0, skipped: 6 preserved (2925 pass / 2931 total).

Closes issue #1936 item (f) Phase 1 of N.

* [autofix.ci] apply automated fixes

* docs(helpers-reservation): strip historical narrative, align banner, complete JSDoc (issue #1936 f)

Apply round-1 review findings on HelpersReservation.ts:

- Banner alignment: 'Copyright ... 2021-2026' → 'Partial Copyright ...
  2021-2025' to match sibling files in src/charging-station/ that carry
  banners (ChargingStation.ts, Bootstrap.ts, BootstrapStateUtils.ts,
  CoherentMeterValuesManager.ts, AutomaticTransactionGenerator.ts,
  ChargingStationWorker.ts). A repo-wide year bump to 2026 is out of
  scope for this refactor.
- Strip historical narrative from @description per AGENTS.md
  documentation convention ('document current state; exclude historical
  evolution'). Old text narrated the extraction event ('Extracted from
  ./Helpers as the first slice of the issue #1936 (item f) file split'),
  which the commit message + git blame already carry permanently.
  Replace with an operational spec describing the module's current
  responsibility: reservation-state predicates + bulk expired-reservation
  cleanup.
- Add missing @returns on removeExpiredReservations. Every other
  exported helper documents its return; the async cleanup did not.
  New wording also encodes the WHY (Promise.allSettled → never
  rethrows, individual failures logged) that was previously only
  implicit in the body.

* docs(helpers-reservation): harmonize JSDoc voice across predicates (issue #1936 f)

Align the three reservation predicates to a single JSDoc voice:
'hasPendingReservation' and 'hasPendingReservations' were 'Checks
if …'; 'hasReservationExpired' was already 'Determines whether …'
after the R1 doc-fix. Standardize the two predicates to
'Determines whether …' so all three read consistently. Leave
'removeExpiredReservations' as imperative ('Removes every …') since
it is a mutation, not a predicate — different verb class,
appropriate.

Per AGENTS.md 'Naming coherence' — semantically accurate names
across code and documentation, avoid synonyms that create
ambiguity.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
src/charging-station/Helpers.ts
src/charging-station/HelpersReservation.ts [new file with mode: 0644]