]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
refactor: convention alignment — helpers, constants, imports, tests (#1950)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 5 Jul 2026 17:20:58 +0000 (19:20 +0200)
committerGitHub <noreply@github.com>
Sun, 5 Jul 2026 17:20:58 +0000 (19:20 +0200)
commit0b0352f495d0ba2ad4915d3187c3554b1da8f6eb
treef0c3da4daf04d646005c1eb9e5f5cccccfe889b5
parent9c8261ea43f531467b0f9e77a8b8bb884fdf2994
refactor: convention alignment — helpers, constants, imports, tests (#1950)

Convention alignment refactor across the monorepo — no behavior change.

Helpers adoption:
- adopt isEmpty() helper for emptiness checks (9 sites); OCPPServiceUtils.ts:1113 preserved with anchor comment (already-trimmed input; isEmpty would redundantly re-trim)
- adopt Constants.UNIT_DIVIDER_KILO for kW→W conversion (4 sites)
- use JSONStringify for unknown MCP tool payload (Map/Set-safe replacer)

Constants promotion:
- promote inline literals to named constants (MAX_ITEMS_PER_REPORT_MESSAGE with OCPP 2.0.1 §2.1.16/§2.1.18 spec-anchor comment; AVG_ENTRY_SIZE_BYTES; DEFAULT_EXPONENTIAL_BACKOFF_BASE_DELAY_MS; DEFAULT_AUTH_CACHE_TTL_SECONDS; DEFAULT_PERSIST_STATE)
- coverage gap: isNotEmptyArray adoption at ConfigurationValidation.ts:124

Imports discipline:
- add .js extension to relative import in ui-web/vitest.config (ESM/NodeNext)
- use component barrels instead of deep imports in tests (10 sites)

Test literals:
- use DEFAULT_HOST/DEFAULT_PORT constants in ui-common tests (72 sites: 32 in config.test.ts + 40 in WebSocketClient.test.ts)

Documentation anchors:
- document Number.parseInt/parseFloat convention exceptions (3 comments covering 4 call sites where convertToInt/convertToFloat cannot substitute)

Quality gates: typecheck clean, lint clean, 2954/2960 tests pass, 0 fail.

Diff: +140/-113 across 28 files.
28 files changed:
src/charging-station/ChargingStation.ts
src/charging-station/CoherentMeterValuesManager.ts
src/charging-station/HelpersConfig.ts
src/charging-station/meter-values/CoherentMeterValueBuilder.ts
src/charging-station/meter-values/CoherentSession.ts
src/charging-station/meter-values/EvProfiles.ts
src/charging-station/ocpp/2.0/OCPP20CertificateManager.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/OCPPServiceUtils.ts
src/charging-station/ocpp/auth/cache/InMemoryAuthCache.ts
src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts
src/charging-station/ui-server/UIMCPServer.ts
src/charging-station/ui-server/UIServerNet.ts
src/utils/Configuration.ts
src/utils/ConfigurationValidation.ts
src/utils/Constants.ts
tests/charging-station/helpers/TemplateFixtures.ts
tests/charging-station/ocpp/2.0/OCPP20CertSigningRetryManager.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts
tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-TransactionEvent.test.ts
tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts
tests/charging-station/ui-server/UIMCPServer.integration.test.ts
tests/charging-station/ui-server/UIMCPServer.test.ts
tests/charging-station/ui-server/UIWebSocketServer.test.ts
tests/charging-station/ui-server/ui-services/AbstractUIService.test.ts
ui/common/tests/WebSocketClient.test.ts
ui/common/tests/config.test.ts
ui/web/vitest.config.ts