Skip to content

Commit

Permalink
chore: post neostandard migration code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
  • Loading branch information
jerome-benoit committed Jul 15, 2024
1 parent d1f5bfd commit a743807
Show file tree
Hide file tree
Showing 17 changed files with 285 additions and 316 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default defineFlatConfig([
files: [
'src/charging-station/ChargingStation.ts',
'src/charging-station/ocpp/OCPPServiceUtils.ts',
'src/charging-station/ocpp/1.6/OCPP16ResponseService.ts',
'src/performance/PerformanceStatistics.ts',
],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"glob": "^11.0.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"neostandard": "^0.11.0",
"neostandard": "^0.11.1",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"semver": "^7.6.2",
Expand Down
332 changes: 166 additions & 166 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions src/charging-station/AutomaticTransactionGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ export class AutomaticTransactionGenerator {
logger.info(
`${this.logPrefix(connectorId)} transaction started with id ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.chargingStation.getConnectorStatus(connectorId)?.transactionId?.toString()
} and will stop in ${formatDurationMilliSeconds(waitTrxEnd)}`
this.chargingStation
.getConnectorStatus(connectorId)
?.transactionId?.toString()} and will stop in ${formatDurationMilliSeconds(waitTrxEnd)}`
)
await sleep(waitTrxEnd)
await this.stopTransaction(connectorId)
Expand All @@ -243,9 +244,10 @@ export class AutomaticTransactionGenerator {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
++this.connectorsStatus.get(connectorId)!.skippedTransactions
logger.info(
`${this.logPrefix(connectorId)} skipped consecutively ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.connectorsStatus.get(connectorId)?.skippedConsecutiveTransactions.toString()
`${this.logPrefix(connectorId)} skipped consecutively ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.connectorsStatus
.get(connectorId)
?.skippedConsecutiveTransactions.toString()
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}/${this.connectorsStatus.get(connectorId)?.skippedTransactions.toString()} transaction(s)`
)
Expand Down Expand Up @@ -341,8 +343,7 @@ export class AutomaticTransactionGenerator {
logger.info(
`${this.logPrefix(connectorId)} entered in transaction loop while a transaction ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
connectorStatus.transactionId?.toString()
} is already started on connector ${connectorId.toString()}`
connectorStatus.transactionId?.toString()} is already started on connector ${connectorId.toString()}`
)
return false
}
Expand Down Expand Up @@ -387,8 +388,7 @@ export class AutomaticTransactionGenerator {
logger.info(
`${this.logPrefix(connectorId)} transaction loop waiting for started transaction ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
connectorStatus.transactionId?.toString()
} on connector ${connectorId.toString()} to be stopped`
connectorStatus.transactionId?.toString()} on connector ${connectorId.toString()} to be stopped`
)
logged = true
}
Expand Down Expand Up @@ -538,10 +538,8 @@ export class AutomaticTransactionGenerator {
let stopResponse: StopTransactionResponse | undefined
if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted === true) {
logger.info(
`${this.logPrefix(connectorId)} stop transaction with id ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.chargingStation.getConnectorStatus(connectorId)?.transactionId?.toString()
}`
`${this.logPrefix(connectorId)} stop transaction with id ${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.chargingStation.getConnectorStatus(connectorId)?.transactionId?.toString()}`
)
stopResponse = await this.chargingStation.stopTransactionOnConnector(connectorId, reason)
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down
42 changes: 14 additions & 28 deletions src/charging-station/Bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,18 @@ export class Bootstrap extends EventEmitter {
)
console.info(
chalk.green(
`Charging stations simulator ${this.version} started with ${
this.numberOfConfiguredChargingStations.toString()
} configured and ${
this.numberOfProvisionedChargingStations.toString()
} provisioned charging station(s) from ${
this.numberOfChargingStationTemplates.toString()
} charging station template(s) and ${
`Charging stations simulator ${this.version} started with ${this.numberOfConfiguredChargingStations.toString()} configured and ${this.numberOfProvisionedChargingStations.toString()} provisioned charging station(s) from ${this.numberOfChargingStationTemplates.toString()} charging station template(s) and ${
Configuration.workerDynamicPoolInUse()
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
? `${workerConfiguration.poolMinSize?.toString()}/`
: ''
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Configuration.workerDynamicPoolInUse() ? `${workerConfiguration.poolMinSize?.toString()}/` : ''
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}${this.workerImplementation?.size.toString()}${
Configuration.workerPoolInUse()
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
? `/${workerConfiguration.poolMaxSize?.toString()}`
: ''
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
Configuration.workerPoolInUse() ? `/${workerConfiguration.poolMaxSize?.toString()}` : ''
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
} worker(s) concurrently running in '${workerConfiguration.processType}' mode${
this.workerImplementation?.maxElementsPerWorker != null
? ` (${this.workerImplementation.maxElementsPerWorker.toString()} charging station(s) per worker)`
Expand Down Expand Up @@ -326,7 +324,7 @@ export class Bootstrap extends EventEmitter {
ChargingStationWorkerMessageEvents.stopped,
this.numberOfStartedChargingStations
)
.then((events) => {
.then(events => {
resolve('Charging stations stopped')
return events
})
Expand Down Expand Up @@ -450,11 +448,7 @@ export class Bootstrap extends EventEmitter {
`${this.logPrefix()} ${moduleName}.workerEventAdded: Charging station ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) added (${
this.numberOfAddedChargingStations.toString()
} added from ${this.numberOfConfiguredChargingStations.toString()} configured and ${
this.numberOfProvisionedChargingStations.toString()
} provisioned charging station(s))`
} (hashId: ${data.stationInfo.hashId}) added (${this.numberOfAddedChargingStations.toString()} added from ${this.numberOfConfiguredChargingStations.toString()} configured and ${this.numberOfProvisionedChargingStations.toString()} provisioned charging station(s))`
)
}

Expand All @@ -468,11 +462,7 @@ export class Bootstrap extends EventEmitter {
`${this.logPrefix()} ${moduleName}.workerEventDeleted: Charging station ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) deleted (${
this.numberOfAddedChargingStations.toString()
} added from ${this.numberOfConfiguredChargingStations.toString()} configured and ${
this.numberOfProvisionedChargingStations.toString()
} provisioned charging station(s))`
} (hashId: ${data.stationInfo.hashId}) deleted (${this.numberOfAddedChargingStations.toString()} added from ${this.numberOfConfiguredChargingStations.toString()} configured and ${this.numberOfProvisionedChargingStations.toString()} provisioned charging station(s))`
)
}

Expand All @@ -484,9 +474,7 @@ export class Bootstrap extends EventEmitter {
`${this.logPrefix()} ${moduleName}.workerEventStarted: Charging station ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) started (${
this.numberOfStartedChargingStations.toString()
} started from ${this.numberOfAddedChargingStations.toString()} added charging station(s))`
} (hashId: ${data.stationInfo.hashId}) started (${this.numberOfStartedChargingStations.toString()} started from ${this.numberOfAddedChargingStations.toString()} added charging station(s))`
)
}

Expand All @@ -498,9 +486,7 @@ export class Bootstrap extends EventEmitter {
`${this.logPrefix()} ${moduleName}.workerEventStopped: Charging station ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
data.stationInfo.chargingStationId
} (hashId: ${data.stationInfo.hashId}) stopped (${
this.numberOfStartedChargingStations.toString()
} started from ${this.numberOfAddedChargingStations.toString()} added charging station(s))`
} (hashId: ${data.stationInfo.hashId}) stopped (${this.numberOfStartedChargingStations.toString()} started from ${this.numberOfAddedChargingStations.toString()} added charging station(s))`
)
}

Expand Down
26 changes: 13 additions & 13 deletions src/charging-station/ChargingStation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class ChargingStation extends EventEmitter {
return new URL(
`${wsConnectionBaseUrlStr}${
!wsConnectionBaseUrlStr.endsWith('/') ? '/' : ''
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
}${this.stationInfo?.chargingStationId}`
)
}
Expand Down Expand Up @@ -434,8 +434,8 @@ export class ChargingStation extends EventEmitter {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
isNaN(connectorChargingProfilesLimit!)
? Number.POSITIVE_INFINITY
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
connectorChargingProfilesLimit!
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
: connectorChargingProfilesLimit!
)
}

Expand Down Expand Up @@ -544,9 +544,7 @@ export class ChargingStation extends EventEmitter {
}
this.stationInfo?.autoRegister === false &&
logger.warn(
`${this.logPrefix()} Heartbeat interval configuration key not set, using default value: ${
Constants.DEFAULT_HEARTBEAT_INTERVAL.toString()
}`
`${this.logPrefix()} Heartbeat interval configuration key not set, using default value: ${Constants.DEFAULT_HEARTBEAT_INTERVAL.toString()}`
)
return Constants.DEFAULT_HEARTBEAT_INTERVAL
}
Expand Down Expand Up @@ -612,7 +610,9 @@ export class ChargingStation extends EventEmitter {

public startMeterValues (connectorId: number, interval: number): void {
if (connectorId === 0) {
logger.error(`${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId.toString()}`)
logger.error(
`${this.logPrefix()} Trying to start MeterValues on connector id ${connectorId.toString()}`
)
return
}
const connectorStatus = this.getConnectorStatus(connectorId)
Expand Down Expand Up @@ -1454,8 +1454,10 @@ export class ChargingStation extends EventEmitter {
}
} else {
for (const connectorId of this.connectors.keys()) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
connectorsPhaseRotation.push(getPhaseRotationValue(connectorId, this.getNumberOfPhases())!)
connectorsPhaseRotation.push(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
getPhaseRotationValue(connectorId, this.getNumberOfPhases())!
)
}
}
addConfigurationKey(
Expand Down Expand Up @@ -1881,10 +1883,8 @@ export class ChargingStation extends EventEmitter {
}
if (!this.isRegistered()) {
logger.error(
`${this.logPrefix()} Registration failure: maximum retries reached (${registrationRetryCount.toString()}) or retry disabled (${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.stationInfo?.registrationMaxRetries?.toString()
})`
`${this.logPrefix()} Registration failure: maximum retries reached (${registrationRetryCount.toString()}) or retry disabled (${// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
this.stationInfo?.registrationMaxRetries?.toString()})`
)
}
this.emit(ChargingStationEvents.updated)
Expand Down
23 changes: 6 additions & 17 deletions src/charging-station/Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ export const initializeConnectorsMapStatus = (
logger.warn(
`${logPrefix} Connector id ${connectorId.toString()} at initialization has a transaction started with id ${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
connectors.get(connectorId)?.transactionId?.toString()
}`
connectors.get(connectorId)?.transactionId?.toString()}`
)
}
if (connectorId === 0) {
Expand Down Expand Up @@ -653,9 +652,7 @@ export const getChargingStationChargingProfilesLimit = (
chargingStation.stationInfo!.maximumPower!
if (limit > chargingStationMaximumPower) {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.getChargingStationChargingProfilesLimit: Charging profile id ${
chargingProfilesLimit.chargingProfile.chargingProfileId.toString()
} limit ${limit.toString()} is greater than charging station maximum ${chargingStationMaximumPower.toString()}: %j`,
`${chargingStation.logPrefix()} ${moduleName}.getChargingStationChargingProfilesLimit: Charging profile id ${chargingProfilesLimit.chargingProfile.chargingProfileId.toString()} limit ${limit.toString()} is greater than charging station maximum ${chargingStationMaximumPower.toString()}: %j`,
chargingProfilesLimit
)
return chargingStationMaximumPower
Expand Down Expand Up @@ -720,9 +717,7 @@ export const getConnectorChargingProfilesLimit = (
chargingStation.stationInfo!.maximumPower! / chargingStation.powerDivider!
if (limit > connectorMaximumPower) {
logger.error(
`${chargingStation.logPrefix()} ${moduleName}.getConnectorChargingProfilesLimit: Charging profile id ${
chargingProfilesLimit.chargingProfile.chargingProfileId.toString()
} limit ${limit.toString()} is greater than connector ${connectorId.toString()} maximum ${connectorMaximumPower.toString()}: %j`,
`${chargingStation.logPrefix()} ${moduleName}.getConnectorChargingProfilesLimit: Charging profile id ${chargingProfilesLimit.chargingProfile.chargingProfileId.toString()} limit ${limit.toString()} is greater than connector ${connectorId.toString()} maximum ${connectorMaximumPower.toString()}: %j`,
chargingProfilesLimit
)
return connectorMaximumPower
Expand Down Expand Up @@ -1094,9 +1089,7 @@ export const canProceedChargingProfile = (
(isValidDate(chargingProfile.validTo) && isAfter(currentDate, chargingProfile.validTo))
) {
logger.debug(
`${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${
chargingProfile.chargingProfileId.toString()
} is not valid for the current date ${
`${logPrefix} ${moduleName}.canProceedChargingProfile: Charging profile id ${chargingProfile.chargingProfileId.toString()} is not valid for the current date ${
isDate(currentDate) ? currentDate.toISOString() : currentDate.toString()
}`
)
Expand Down Expand Up @@ -1246,9 +1239,7 @@ const checkRecurringChargingProfileDuration = (
logger.warn(
`${logPrefix} ${moduleName}.checkRecurringChargingProfileDuration: Recurring ${
chargingProfile.chargingProfileKind
} charging profile id ${
chargingProfile.chargingProfileId.toString()
} duration is not defined, set it to the recurrency time interval duration ${differenceInSeconds(
} charging profile id ${chargingProfile.chargingProfileId.toString()} duration is not defined, set it to the recurrency time interval duration ${differenceInSeconds(
interval.end,
interval.start
).toString()}`
Expand All @@ -1260,9 +1251,7 @@ const checkRecurringChargingProfileDuration = (
logger.warn(
`${logPrefix} ${moduleName}.checkRecurringChargingProfileDuration: Recurring ${
chargingProfile.chargingProfileKind
} charging profile id ${chargingProfile.chargingProfileId.toString()} duration ${
chargingProfile.chargingSchedule.duration.toString()
} is greater than the recurrency time interval duration ${differenceInSeconds(
} charging profile id ${chargingProfile.chargingProfileId.toString()} duration ${chargingProfile.chargingSchedule.duration.toString()} is greater than the recurrency time interval duration ${differenceInSeconds(
interval.end,
interval.start
).toString()}`
Expand Down
Loading

0 comments on commit a743807

Please sign in to comment.