]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
refactor: use utility functions consistently across codebase
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 3 Apr 2026 16:33:14 +0000 (18:33 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 3 Apr 2026 16:33:14 +0000 (18:33 +0200)
commit55bc07156902469266f5c66b37f75d57ec49ad16
treefdc51a1097ea03469b3d65bec00d9c7da2da5569
parentb1b03bf7a9ad234e00822950a791b1befd82ec0b
refactor: use utility functions consistently across codebase

Replace manual patterns with existing utility functions to improve DRY
compliance:

- Use isEmpty/isNotEmptyArray/isNotEmptyString instead of .length checks
- Use convertToInt/convertToFloat instead of Number.parseInt/Number
- Use roundTo instead of Math.round(x * N) / N
- Use ensureError in catch blocks for proper error type narrowing
- Add UNIT_DIVIDER_KILO, MILLISECONDS_PER_HOUR and
  DEFAULT_EXPONENTIAL_BACKOFF_JITTER_MS to Constants

Note: isEmpty/isNotEmptyString apply whitespace trimming, which
tightens validation for identifiers and configuration values.
20 files changed:
src/charging-station/ChargingStation.ts
src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20CertificateManager.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts
src/charging-station/ocpp/2.0/OCPP20VariableManager.ts
src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts
src/charging-station/ocpp/auth/adapters/OCPP16AuthAdapter.ts
src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts
src/charging-station/ocpp/auth/cache/InMemoryAuthCache.ts
src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts
src/charging-station/ocpp/auth/utils/AuthHelpers.ts
src/charging-station/ocpp/auth/utils/AuthValidators.ts
src/charging-station/ocpp/auth/utils/ConfigValidator.ts
src/charging-station/ui-server/UIMCPServer.ts
src/charging-station/ui-server/ui-services/AbstractUIService.ts
src/utils/Configuration.ts
src/utils/Logger.ts
src/utils/StatisticUtils.ts