From 47960b8565208e93a3956e21374e8304d322c1c1 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 6 Dec 2023 10:51:35 -0500 Subject: [PATCH] fix(striker-ui-api): replace all instances of parseInt --- striker-ui-api/src/lib/accessModule.ts | 2 +- striker-ui-api/src/lib/disassembleEntityId.ts | 4 ++-- .../request_handlers/anvil/buildQueryAnvilDetail.ts | 10 +++++----- .../src/lib/request_handlers/host/getHostConnection.ts | 6 +++--- .../lib/request_handlers/manifest/getManifestDetail.ts | 4 ++-- .../request_handlers/manifest/getManifestTemplate.ts | 2 +- .../lib/request_handlers/ssh-key/getSSHKeyConflict.ts | 2 +- striker-ui-api/src/lib/shell.ts | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/striker-ui-api/src/lib/accessModule.ts b/striker-ui-api/src/lib/accessModule.ts index 8782298c..94a0f6aa 100644 --- a/striker-ui-api/src/lib/accessModule.ts +++ b/striker-ui-api/src/lib/accessModule.ts @@ -463,7 +463,7 @@ const getVncinfo = async (serverUuid: string): Promise => { const [[vncinfo]] = rows; const [domain, rPort] = vncinfo.split(':'); - const port = Number.parseInt(rPort); + const port = Number(rPort); const protocol = 'ws'; return { domain, port, protocol }; diff --git a/striker-ui-api/src/lib/disassembleEntityId.ts b/striker-ui-api/src/lib/disassembleEntityId.ts index 609d46f3..cceb1b81 100644 --- a/striker-ui-api/src/lib/disassembleEntityId.ts +++ b/striker-ui-api/src/lib/disassembleEntityId.ts @@ -1,7 +1,7 @@ export const getEntityName = (id: string) => id.replace(/\d*$/, ''); export const getEntityNumber = (id: string) => - Number.parseInt(id.replace(/^[^\d]*/, '')); + Number(id.replace(/^[^\d]*/, '')); export const getEntityParts = (id: string) => { let name = ''; @@ -13,7 +13,7 @@ export const getEntityParts = (id: string) => { const parts = matchResult; name = parts[1]; - number = Number.parseInt(parts[2]); + number = Number(parts[2]); } return { name, number }; diff --git a/striker-ui-api/src/lib/request_handlers/anvil/buildQueryAnvilDetail.ts b/striker-ui-api/src/lib/request_handlers/anvil/buildQueryAnvilDetail.ts index 331afa0b..7b75c83a 100644 --- a/striker-ui-api/src/lib/request_handlers/anvil/buildQueryAnvilDetail.ts +++ b/striker-ui-api/src/lib/request_handlers/anvil/buildQueryAnvilDetail.ts @@ -263,12 +263,12 @@ const buildQueryAnvilDetail = ({ anvilUUID, anvilName, anvilDescription, - anvilTotalCPUCores: parseInt(anvilTotalCPUCores), + anvilTotalCPUCores: Number(anvilTotalCPUCores), anvilTotalMemory: String(anvilTotalMemory), - anvilTotalAllocatedCPUCores: parseInt( + anvilTotalAllocatedCPUCores: Number( anvilTotalAllocatedCPUCores, ), - anvilTotalAvailableCPUCores: parseInt( + anvilTotalAvailableCPUCores: Number( anvilTotalAvailableCPUCores, ), } as AnvilDetailForProvisionServer; @@ -280,7 +280,7 @@ const buildQueryAnvilDetail = ({ hosts[hostUUID] = { hostUUID, hostName, - hostCPUCores: parseInt(hostCPUCores), + hostCPUCores: Number(hostCPUCores), hostMemory: String(hostMemory), }; } @@ -297,7 +297,7 @@ const buildQueryAnvilDetail = ({ servers[serverUUID] = { serverUUID, serverName, - serverCPUCores: parseInt(serverCPUCores), + serverCPUCores: Number(serverCPUCores), serverMemory, }; } diff --git a/striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts b/striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts index f4cbe8e8..ac47c2c0 100644 --- a/striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts +++ b/striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts @@ -15,7 +15,7 @@ const buildHostConnections = ( ) => Object.entries(databaseHash).reduce( (previous, [hostUUID, { host: ipAddress, ping, port: rawPort, user }]) => { - const port = parseInt(rawPort); + const port = Number(rawPort); if (hostUUID === fromHostUUID) { previous.inbound.port = port; @@ -91,8 +91,8 @@ export const getHostConnection = buildGetRequestHandler( hostUUID, ipAddress, ipAddressUUID, - networkLinkNumber: parseInt(rawNetworkLinkNumber), - networkNumber: parseInt(rawNetworkNumber), + networkLinkNumber: Number(rawNetworkLinkNumber), + networkNumber: Number(rawNetworkNumber), networkType, }; }, diff --git a/striker-ui-api/src/lib/request_handlers/manifest/getManifestDetail.ts b/striker-ui-api/src/lib/request_handlers/manifest/getManifestDetail.ts index fcabc918..e5c802f5 100644 --- a/striker-ui-api/src/lib/request_handlers/manifest/getManifestDetail.ts +++ b/striker-ui-api/src/lib/request_handlers/manifest/getManifestDetail.ts @@ -217,7 +217,7 @@ export const getManifestDetail: RequestHandler = async (request, response) => { name, networkConfig: { dnsCsv, - mtu: Number.parseInt(mtu), + mtu: Number(mtu), networks: Object.entries(networkList) .sort(handleSortNetworks) .reduce( @@ -252,7 +252,7 @@ export const getManifestDetail: RequestHandler = async (request, response) => { ntpCsv, }, prefix, - sequence: Number.parseInt(sequence), + sequence: Number(sequence), }; response.status(200).send(manifestData); diff --git a/striker-ui-api/src/lib/request_handlers/manifest/getManifestTemplate.ts b/striker-ui-api/src/lib/request_handlers/manifest/getManifestTemplate.ts index 3e893be5..055e5ead 100644 --- a/striker-ui-api/src/lib/request_handlers/manifest/getManifestTemplate.ts +++ b/striker-ui-api/src/lib/request_handlers/manifest/getManifestTemplate.ts @@ -105,7 +105,7 @@ export const getManifestTemplate: RequestHandler = async ( } if (lastSequence) { - previous.sequence = Number.parseInt(lastSequence) + 1; + previous.sequence = Number(lastSequence) + 1; } return previous; diff --git a/striker-ui-api/src/lib/request_handlers/ssh-key/getSSHKeyConflict.ts b/striker-ui-api/src/lib/request_handlers/ssh-key/getSSHKeyConflict.ts index d808e64c..26ff5406 100644 --- a/striker-ui-api/src/lib/request_handlers/ssh-key/getSSHKeyConflict.ts +++ b/striker-ui-api/src/lib/request_handlers/ssh-key/getSSHKeyConflict.ts @@ -38,7 +38,7 @@ export const getSSHKeyConflict = buildGetRequestHandler( previous[hostUUIDKey][stateUUID] = { badFile, - badLine: parseInt(badLine), + badLine: Number(badLine), hostName, hostUUID, ipAddress, diff --git a/striker-ui-api/src/lib/shell.ts b/striker-ui-api/src/lib/shell.ts index 72c51fe9..0caf38e9 100644 --- a/striker-ui-api/src/lib/shell.ts +++ b/striker-ui-api/src/lib/shell.ts @@ -48,7 +48,7 @@ export const uuidgen = (...args: string[]) => systemCall(SERVER_PATHS.usr.bin.uuidgen.self, args); export const resolveId = (id: number | string, database: string) => - Number.parseInt(getent(database, String(id)).split(':', 3)[2]); + Number(getent(database, String(id)).split(':', 3)[2]); export const resolveGid = (id: number | string) => resolveId(id, 'group');