Behavior-preserving codebase style-consistency sweep. Closes #1966.
- Backtick 49 JSDoc @returns boolean literals across 17 files (lowercase True/False).
- Align !== undefined -> != null on number|undefined guards in OCPP20IncomingRequestService.ts (13 tokens); conditional-spread inclusion guards preserved as !== undefined.
- Extend != null idiom to OCPP20VariableManager min/max ternaries + presence guards and the negated EVSE guard.
- Fix OCPP20AuthAdapter.validateConfiguration @returns (synchronous boolean; was falsely 'Promise resolving to').
Gap C (String(previousRequestId) -> .toString()) dropped: premise false — operand is number|undefined, .toString() would fail typecheck (TS18048); String() is the only behavior-preserving form.
All gates green (format/typecheck/lint/build/test, fail=0). Reviewed across multiple multi-agent rounds with cross-validation.
* @param reservationId - The reservation ID to check
* @param idTag - Optional ID tag for user reservation check
* @param connectorId - Optional connector ID to check availability
- * @returns True if the connector can accept a reservation
+ * @returns `true` if the connector can accept a reservation
*/
public isConnectorReservable (
reservationId: number,
* @param stationHashId - Charging station unique identifier
* @param certificateHashData - Certificate hash data to check against stored CS certificates
* @param hashAlgorithm - Optional hash algorithm override (defaults to certificateHashData.hashAlgorithm)
- * @returns true if the hash matches a stored ChargingStationCertificate, false otherwise
+ * @returns `true` if the hash matches a stored ChargingStationCertificate, `false` otherwise
*/
public async isChargingStationCertificateHash (
stationHashId: string,
/**
* Validates PEM certificate format
* @param pemData - PEM data to validate
- * @returns true if valid PEM certificate format, false otherwise
+ * @returns `true` if valid PEM certificate format, `false` otherwise
*/
public validateCertificateFormat (pemData: unknown): boolean {
if (pemData == null || typeof pemData !== 'string') {
/**
* Type guard to check if a charging station has a certificate manager
* @param chargingStation - The charging station to check
- * @returns true if the charging station has a certificate manager
+ * @returns `true` if the charging station has a certificate manager
*/
export function hasCertificateManager (
chargingStation: ChargingStation
commandPayload: OCPP20ResetRequest
): Promise<OCPP20ResetResponse> {
logger.debug(
- `${chargingStation.logPrefix()} ${moduleName}.handleRequestReset: Reset request received with type ${commandPayload.type}${commandPayload.evseId !== undefined ? ` for EVSE ${commandPayload.evseId.toString()}` : ''}`
+ `${chargingStation.logPrefix()} ${moduleName}.handleRequestReset: Reset request received with type ${commandPayload.type}${commandPayload.evseId != null ? ` for EVSE ${commandPayload.evseId.toString()}` : ''}`
)
const { evseId, type } = commandPayload
}
}
- if (evseId !== undefined && evseId > 0) {
+ if (evseId != null && evseId > 0) {
if (!chargingStation.hasEvses) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestReset: Charging station does not support EVSE-specific reset`
const hasActiveTransactions = chargingStation.getNumberOfRunningTransactions() > 0
let evseHasActiveTransactions = false
- if (evseId !== undefined && evseId > 0) {
+ if (evseId != null && evseId > 0) {
const evse = chargingStation.getEvseStatus(evseId)
if (evse != null) {
evseHasActiveTransactions = this.hasEvseActiveTransactions(evse)
try {
if (type === ResetEnumType.Immediate) {
- if (evseId !== undefined && evseId > 0) {
+ if (evseId != null && evseId > 0) {
if (evseHasActiveTransactions) {
logger.info(
`${chargingStation.logPrefix()} ${moduleName}.handleRequestReset: Immediate EVSE reset with active transaction, will terminate transaction and reset EVSE ${evseId.toString()}`
}
}
} else {
- if (evseId !== undefined && evseId > 0) {
+ if (evseId != null && evseId > 0) {
const evse = chargingStation.getEvseStatus(evseId)
if (evse != null && !this.isEvseIdle(chargingStation, evse)) {
logger.info(
const { evse, requestedMessage } = commandPayload
logger.debug(
- `${chargingStation.logPrefix()} ${moduleName}.handleRequestTriggerMessage: TriggerMessage received for '${requestedMessage}'${evse?.id !== undefined ? ` on EVSE ${evse.id.toString()}` : ''}`
+ `${chargingStation.logPrefix()} ${moduleName}.handleRequestTriggerMessage: TriggerMessage received for '${requestedMessage}'${evse?.id != null ? ` on EVSE ${evse.id.toString()}` : ''}`
)
switch (requestedMessage) {
/**
* Checks if a specific EVSE has any active transactions.
* @param evse - The EVSE to check
- * @returns true if any connector on the EVSE has an active transaction
+ * @returns `true` if any connector on the EVSE has an active transaction
*/
private hasEvseActiveTransactions (evse: EvseStatus): boolean {
for (const connector of evse.connectors.values()) {
/**
* Checks if a specific EVSE has any non-expired reservations.
* @param evse - The EVSE to check
- * @returns true if any connector on the EVSE has a pending reservation
+ * @returns `true` if any connector on the EVSE has a pending reservation
*/
private hasEvsePendingReservations (evse: EvseStatus): boolean {
for (const connector of evse.connectors.values()) {
* Idle means: no active transactions, no firmware update in progress, no pending reservations.
* Note: Log uploads and cable lock state are not tracked in the simulator.
* @param chargingStation - The charging station instance
- * @returns true if charging station is idle
+ * @returns `true` if charging station is idle
*/
private isChargingStationIdle (chargingStation: ChargingStation): boolean {
return (
* Idle means: no active transactions on EVSE, no firmware update in progress, no pending reservations on EVSE.
* @param chargingStation - The charging station instance
* @param evse - The EVSE to check
- * @returns true if EVSE is idle
+ * @returns `true` if EVSE is idle
*/
private isEvseIdle (chargingStation: ChargingStation, evse: EvseStatus): boolean {
return (
evse: OCPP20TriggerMessageRequest['evse'],
errorHandler: (error: unknown) => void
): void {
- if (evse?.id !== undefined && evse.id > 0 && evse.connectorId !== undefined) {
+ if (evse?.id != null && evse.id > 0 && evse.connectorId != null) {
const evseStatus = chargingStation.getEvseStatus(evse.id)
const connectorStatus = evseStatus?.connectors.get(evse.connectorId)
const resolvedStatus = connectorStatus?.status ?? ConnectorStatusEnum.Available
* @param chargingStation - The charging station instance
* @param chargingProfile - The charging profile to validate
* @param evseId - EVSE identifier
- * @returns True if purpose validation passes, false otherwise
+ * @returns `true` if purpose validation passes, `false` otherwise
*/
private validateChargingProfilePurpose (
chargingStation: ChargingStation,
* @param scheduleIndex - Index of the schedule in the profile's schedule array
* @param chargingProfile - The parent charging profile
* @param evseId - EVSE identifier
- * @returns True if schedule is valid, false otherwise
+ * @returns `true` if schedule is valid, `false` otherwise
*/
private validateChargingSchedule (
chargingStation: ChargingStation,
return false
}
- if (schedule.duration !== undefined && schedule.duration <= 0) {
+ if (schedule.duration != null && schedule.duration <= 0) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.validateChargingSchedule: Schedule duration must be positive if specified`
)
return false
}
- if (schedule.minChargingRate !== undefined && schedule.minChargingRate < 0) {
+ if (schedule.minChargingRate != null && schedule.minChargingRate < 0) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.validateChargingSchedule: Minimum charging rate cannot be negative`
)
return false
}
- if (schedule.minChargingRate !== undefined && period.limit < schedule.minChargingRate) {
+ if (schedule.minChargingRate != null && period.limit < schedule.minChargingRate) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.validateChargingSchedule: Period ${periodIndex.toString()} limit cannot be below minimum charging rate`
)
return false
}
- if (period.numberPhases !== undefined) {
+ if (period.numberPhases != null) {
if (period.numberPhases < 1 || period.numberPhases > 3) {
logger.warn(
`${chargingStation.logPrefix()} ${moduleName}.validateChargingSchedule: Period ${periodIndex.toString()} number of phases must be 1-3`
}
if (
- period.phaseToUse !== undefined &&
+ period.phaseToUse != null &&
(period.phaseToUse < 1 || period.phaseToUse > period.numberPhases)
) {
logger.warn(
chargingStation: ChargingStation,
evse: OCPP20TriggerMessageRequest['evse']
): OCPP20TriggerMessageResponse | undefined {
- if (evse?.id === undefined || evse.id <= 0) {
+ if (evse?.id == null || evse.id <= 0) {
return undefined
}
if (!chargingStation.hasEvses) {
if (resolvedAttributeType === AttributeEnumType.MinSet) {
if (
- variableMetadata.min === undefined &&
+ variableMetadata.min == null &&
this.getMinSetOverrides(stationId).get(variableKey) == null
) {
return this.rejectGet(
}
const minValue =
this.getMinSetOverrides(stationId).get(variableKey) ??
- (variableMetadata.min !== undefined ? variableMetadata.min.toString() : '')
+ (variableMetadata.min != null ? variableMetadata.min.toString() : '')
return {
attributeStatus: GetVariableStatusEnumType.Accepted,
attributeType: resolvedAttributeType,
}
if (resolvedAttributeType === AttributeEnumType.MaxSet) {
if (
- variableMetadata.max === undefined &&
+ variableMetadata.max == null &&
this.getMaxSetOverrides(stationId).get(variableKey) == null
) {
return this.rejectGet(
}
const maxValue =
this.getMaxSetOverrides(stationId).get(variableKey) ??
- (variableMetadata.max !== undefined ? variableMetadata.max.toString() : '')
+ (variableMetadata.max != null ? variableMetadata.max.toString() : '')
return {
attributeStatus: GetVariableStatusEnumType.Accepted,
attributeType: resolvedAttributeType,
if (resolvedAttributeType === AttributeEnumType.MinSet) {
const currentMax =
this.getMaxSetOverrides(stationId).get(variableKey) ??
- (variableMetadata.max !== undefined ? variableMetadata.max.toString() : undefined)
+ (variableMetadata.max != null ? variableMetadata.max.toString() : undefined)
if (currentMax != null && intValue > convertToIntOrNaN(currentMax)) {
return this.rejectSet(
variable,
} else {
const currentMin =
this.getMinSetOverrides(stationId).get(variableKey) ??
- (variableMetadata.min !== undefined ? variableMetadata.min.toString() : undefined)
+ (variableMetadata.min != null ? variableMetadata.min.toString() : undefined)
if (currentMin != null && intValue < convertToIntOrNaN(currentMin)) {
return this.rejectSet(
variable,
/**
* Check if variable metadata is persistent.
* @param variableMetadata - Variable metadata entry.
- * @returns True when persistence is Persistent.
+ * @returns `true` when persistence is Persistent.
*/
export function isPersistent (variableMetadata: VariableMetadata): boolean {
return variableMetadata.persistence === PersistenceEnumType.Persistent
/**
* Check if variable metadata is read-only.
* @param variableMetadata - Variable metadata entry.
- * @returns True when mutability is ReadOnly.
+ * @returns `true` when mutability is ReadOnly.
*/
export function isReadOnly (variableMetadata: VariableMetadata): boolean {
return variableMetadata.mutability === MutabilityEnumType.ReadOnly
/**
* Check if variable metadata is write-only.
* @param variableMetadata - Variable metadata entry.
- * @returns True when mutability is WriteOnly.
+ * @returns `true` when mutability is WriteOnly.
*/
export function isWriteOnly (variableMetadata: VariableMetadata): boolean {
return variableMetadata.mutability === MutabilityEnumType.WriteOnly
* Validates whether a component is supported by the charging station.
* @param chargingStation - The charging station instance
* @param component - The component to validate
- * @returns true if the component is valid/supported
+ * @returns `true` if the component is valid/supported
*/
isComponentValid: (chargingStation: ChargingStation, component: ComponentType) => boolean
* Checks whether a variable is supported for the given component.
* @param component - The component containing the variable
* @param variable - The variable to check
- * @returns true if the variable is supported
+ * @returns `true` if the variable is supported
*/
isVariableSupported: (component: ComponentType, variable: VariableType) => boolean
}
/**
* Check if remote authorization is available
- * @returns True if remote authorization is enabled and station is online
+ * @returns `true` if remote authorization is enabled and station is online
*/
isRemoteAvailable (): boolean {
try {
/**
* Check if identifier is valid for OCPP 1.6
* @param identifier - Identifier to validate
- * @returns True if identifier has valid ID_TAG type and length within OCPP 1.6 limits
+ * @returns `true` if identifier has valid ID_TAG type and length within OCPP 1.6 limits
*/
isValidIdentifier (identifier: Identifier): boolean {
// OCPP 1.6 idTag validation
/**
* Validate adapter configuration for OCPP 1.6
* @param config - Auth configuration to validate
- * @returns True if configuration has valid auth methods and timeout values
+ * @returns `true` if configuration has valid auth methods and timeout values
*/
validateConfiguration (config: AuthConfiguration): boolean {
try {
/**
* Check if offline transactions are allowed for unknown IDs
- * @returns True if offline transactions are allowed for unknown IDs
+ * @returns `true` if offline transactions are allowed for unknown IDs
*/
private getOfflineTransactionConfig (): boolean {
try {
/**
* Check if remote authorization is available for OCPP 2.0.1
- * @returns True if remote authorization is available and enabled
+ * @returns `true` if remote authorization is available and enabled
*/
isRemoteAvailable (): boolean {
try {
/**
* Check if identifier is valid for OCPP 2.0.1
* @param identifier - Identifier to validate against OCPP 2.0.1 rules
- * @returns True if identifier meets OCPP 2.0.1 format requirements (max 36 chars, valid type)
+ * @returns `true` if identifier meets OCPP 2.0.1 format requirements (max 36 chars, valid type)
*/
isValidIdentifier (identifier: Identifier): boolean {
// OCPP 2.0.1 idToken validation
/**
* Validate adapter configuration for OCPP 2.0.1
* @param config - Authentication configuration to validate
- * @returns Promise resolving to true if configuration is valid for OCPP 2.0.1 operations
+ * @returns `true` if configuration is valid for OCPP 2.0.1 operations
*/
validateConfiguration (config: AuthConfiguration): boolean {
try {
/**
* Check if offline authorization is allowed
- * @returns True if offline authorization is enabled
+ * @returns `true` if offline authorization is enabled
*/
private getOfflineAuthorizationConfig (): boolean {
try {
/**
* Check if identifier has exceeded rate limit
* @param identifier - Identifier to check
- * @returns true if within rate limit, false if exceeded
+ * @returns `true` if within rate limit, `false` if exceeded
*/
private checkRateLimit (identifier: string): boolean {
if (!this.rateLimit.enabled) {
* Check if this strategy can handle the given request
* @param request - Authentication request
* @param config - Current configuration
- * @returns True if strategy can handle the request
+ * @returns `true` if strategy can handle the request
*/
canHandle(request: AuthRequest, config: AuthConfiguration): boolean
/**
* Check if authentication is supported for given identifier type
* @param identifier - Identifier to check for support
- * @returns True if at least one strategy can handle the identifier type, false otherwise
+ * @returns `true` if at least one strategy can handle the identifier type, `false` otherwise
*/
public isSupported (identifier: Identifier): boolean {
const testRequest: AuthRequest = {
/**
* Test connectivity to remote authorization service
- * @returns True if remote authorization service is reachable
+ * @returns `true` if remote authorization service is reachable
*/
public testConnectivity (): boolean {
const remoteStrategy = this.strategies.get('remote')
/**
* Check if an error should stop the authentication chain
* @param error - Error to evaluate for criticality
- * @returns True if the error should halt authentication attempts, false to continue trying other strategies
+ * @returns `true` if the error should halt authentication attempts, `false` to continue trying other strategies
*/
private isCriticalError (error: Error): boolean {
// Critical errors that should stop trying other strategies
* Check if this strategy can handle the given request
* @param request - Authorization request to evaluate for certificate-based handling
* @param config - Authentication configuration with certificate settings
- * @returns True if the request contains valid certificate data and certificate auth is enabled
+ * @returns `true` if the request contains valid certificate data and certificate auth is enabled
*/
canHandle (request: AuthRequest, config: AuthConfiguration): boolean {
// Only handle certificate-based authentication
/**
* Check if the identifier contains certificate data
* @param identifier - Identifier to check for certificate hash data
- * @returns True if all required certificate hash fields are present and non-empty
+ * @returns `true` if all required certificate hash fields are present and non-empty
*/
private hasCertificateData (identifier: Identifier): boolean {
const certData = identifier.certificateHashData
* Simulate certificate validation (in real implementation, this would involve crypto operations)
* @param request - Authorization request containing certificate data to validate
* @param config - Authentication configuration with validation strictness settings
- * @returns True if the certificate passes simulated validation checks
+ * @returns `true` if the certificate passes simulated validation checks
*/
private async simulateCertificateValidation (
request: AuthRequest,
* Check if this strategy can handle the authentication request
* @param request - Authorization request to evaluate
* @param config - Authentication configuration with local auth settings
- * @returns True if local list, cache, or offline authorization is enabled
+ * @returns `true` if local list, cache, or offline authorization is enabled
*/
public canHandle (request: AuthRequest, config: AuthConfiguration): boolean {
// Can handle if local list is enabled OR cache is enabled OR offline is allowed
/**
* Check if identifier is in local authorization list
* @param identifier - Unique identifier string to look up
- * @returns True if the identifier exists in the local authorization list
+ * @returns `true` if the identifier exists in the local authorization list
*/
public isInLocalList (identifier: string): boolean {
if (!this.localAuthListManager) {
* When DisablePostAuthorize is true or not configured, local results are returned as-is.
* @param result - Authorization result from cache or local list
* @param config - Authentication configuration with disablePostAuthorize setting
- * @returns True if the result should be discarded to trigger remote re-authorization
+ * @returns `true` if the result should be discarded to trigger remote re-authorization
*/
private shouldTriggerPostAuthorize (
result: AuthorizationResult,
* Check if this strategy can handle the authentication request
* @param request - Authorization request to evaluate
* @param config - Authentication configuration with remote authorization settings
- * @returns True if an adapter is available and remote auth is enabled
+ * @returns `true` if an adapter is available and remote auth is enabled
*/
public canHandle (request: AuthRequest, config: AuthConfiguration): boolean {
// Can handle if we have an adapter
/**
* Test connectivity to remote authorization service
- * @returns True if the OCPP adapter can reach its remote service
+ * @returns `true` if the OCPP adapter can reach its remote service
*/
public testConnectivity (): boolean {
if (!this.isInitialized || this.adapter == null) {
* Check if remote authorization service is available
* @param adapter - OCPP adapter to check for remote service availability
* @param _config - Authentication configuration (unused)
- * @returns True if the remote service responds
+ * @returns `true` if the remote service responds
*/
private checkRemoteAvailability (adapter: OCPPAuthAdapter, _config: AuthConfiguration): boolean {
try {
/**
* Check if identifier type is certificate-based
* @param type - Identifier type to check
- * @returns True if certificate-based
+ * @returns `true` if certificate-based
*/
export const isCertificateBased = (type: IdentifierType): boolean => {
return type === IdentifierType.CERTIFICATE
/**
* Check if identifier type is OCPP 1.6 compatible
* @param type - Identifier type to check
- * @returns True if OCPP 1.6 type
+ * @returns `true` if OCPP 1.6 type
*/
export const isOCPP16Type = (type: IdentifierType): boolean => {
return type === IdentifierType.ID_TAG
/**
* Check if identifier type is OCPP 2.0.1 compatible
* @param type - Identifier type to check
- * @returns True if OCPP 2.0.1 type
+ * @returns `true` if OCPP 2.0.1 type
*/
export const isOCPP20Type = (type: IdentifierType): boolean => {
return (Object.values(OCPP20IdTokenEnumType) as string[]).includes(type)
/**
* Check if identifier type requires additional information
* @param type - Identifier type to check
- * @returns True if additional info is required
+ * @returns `true` if additional info is required
*/
export const requiresAdditionalInfo = (type: IdentifierType): boolean => {
return [
/**
* Check whether an authorization result represents a permanent failure.
* @param result - Authorization result to evaluate
- * @returns True if BLOCKED, EXPIRED, or INVALID
+ * @returns `true` if BLOCKED, EXPIRED, or INVALID
*/
function isPermanentFailure (result: AuthorizationResult): boolean {
return [
/**
* Check whether an authorization result is still valid (ACCEPTED and not expired).
* @param result - Authorization result to evaluate
- * @returns True if ACCEPTED and expiry date has not passed
+ * @returns `true` if ACCEPTED and expiry date has not passed
*/
function isResultValid (result: AuthorizationResult): boolean {
if (result.status !== AuthorizationStatus.ACCEPTED) {
/**
* Check whether an authorization result represents a temporary failure.
* @param result - Authorization result to evaluate
- * @returns True if PENDING or UNKNOWN
+ * @returns `true` if PENDING or UNKNOWN
*/
function isTemporaryFailure (result: AuthorizationResult): boolean {
if (result.status === AuthorizationStatus.PENDING) {
/**
* Validate cache TTL value
* @param ttl - Cache time-to-live duration in seconds, or undefined for optional parameter
- * @returns True if the TTL is undefined or a valid non-negative finite number, false otherwise
+ * @returns `true` if the TTL is undefined or a valid non-negative finite number, `false` otherwise
*/
function isValidCacheTTL (ttl: number | undefined): boolean {
if (ttl === undefined) {
/**
* Validate connector ID
* @param connectorId - Charging connector identifier (0 or positive integer), or undefined for optional parameter
- * @returns True if the connector ID is undefined or a valid non-negative integer, false otherwise
+ * @returns `true` if the connector ID is undefined or a valid non-negative integer, `false` otherwise
*/
function isValidConnectorId (connectorId: number | undefined): boolean {
if (connectorId === undefined) {
/**
* Validate that a string is a valid identifier value
* @param value - Authentication identifier string to validate (idTag or IdToken value)
- * @returns True if the value is a non-empty string with at least one non-whitespace character, false otherwise
+ * @returns `true` if the value is a non-empty string with at least one non-whitespace character, `false` otherwise
*/
function isValidIdentifierValue (value: string): boolean {
return isNotEmptyString(value)
/**
* Validate authentication configuration
* @param config - Authentication configuration object to validate (may be any type)
- * @returns True if the configuration has valid required fields and constraints, false otherwise
+ * @returns `true` if the configuration has valid required fields and constraints, `false` otherwise
*/
function validateAuthConfiguration (config: unknown): boolean {
if (!config || typeof config !== 'object') {
/**
* Validate identifier format and constraints
* @param identifier - Identifier object to validate (may be any type)
- * @returns True if the identifier has a valid type and value within OCPP length constraints, false otherwise
+ * @returns `true` if the identifier has a valid type and value within OCPP length constraints, `false` otherwise
*/
function validateIdentifier (identifier: unknown): boolean {
// Check if identifier itself is valid
* @param value - value to write at the leaf
* @param source - originating deprecated key (for error messages)
* @param fieldErrors - error accumulator
- * @returns true on write or no-op, false when an error is recorded
+ * @returns `true` on write or no-op, `false` when an error is recorded
*/
const setAtPath = (
target: Record<string, unknown>,