]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
refactor: eliminate all non-null assertion suppressions with proper null guards
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Mar 2026 18:50:01 +0000 (19:50 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Mar 2026 18:50:01 +0000 (19:50 +0100)
commit5959eb2df872dbdb27032bfd114024be38c32749
tree9a81068910fc594399b20d17a44095c3153168ca
parentc5545f1b865528bf8adbd46df04eac6f4c3148bf
refactor: eliminate all non-null assertion suppressions with proper null guards

Remove 104 eslint-disable-next-line @typescript-eslint/no-non-null-assertion
suppressions across 23 files by replacing non-null assertions (!) with
semantically correct alternatives: local variable extraction with null
guards, optional chaining (?.), nullish coalescing (??) with proper
default constants, and error logging for invalid states.

Key improvements:
- Use existing DEFAULT_POOL_MAX_SIZE, DEFAULT_POOL_MIN_SIZE, and
  DEFAULT_ELEMENTS_PER_WORKER constants instead of hardcoded fallbacks
- Add proper error logging for powerDivider undefined/invalid states
  instead of silently computing wrong values
- Add connectorId null guard with throw in handleMeterValues instead of
  silently defaulting to connector 0
- Ensure .finally() always sends a response to prevent caller hangs
- Align variable naming with codebase conventions (connectorStatus,
  templateStatistics, commandStatisticsData, entryStatisticsData)
23 files changed:
src/charging-station/Bootstrap.ts
src/charging-station/ChargingStation.ts
src/charging-station/ConfigurationKeyUtils.ts
src/charging-station/Helpers.ts
src/charging-station/IdTagsCache.ts
src/charging-station/SharedLRUCache.ts
src/charging-station/broadcast-channel/ChargingStationWorkerBroadcastChannel.ts
src/charging-station/broadcast-channel/UIServiceWorkerBroadcastChannel.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/OCPPIncomingRequestService.ts
src/charging-station/ocpp/OCPPResponseService.ts
src/charging-station/ocpp/OCPPServiceUtils.ts
src/charging-station/ui-server/ui-services/AbstractUIService.ts
src/performance/PerformanceStatistics.ts
src/utils/AsyncLock.ts
src/utils/Configuration.ts
src/utils/Logger.ts
src/utils/MessageChannelUtils.ts
src/worker/WorkerSet.ts