From 8e9ea03d989854c3e0816839ad3a422ed0e158b0 Mon Sep 17 00:00:00 2001 From: Nigel Breslaw Date: Fri, 26 Jul 2024 21:40:51 +0300 Subject: [PATCH] refactor: Small sonarqube fixes (#2165) --- minifier/next_gen.ts | 11 ----------- native/app/Root.tsx | 12 +++++------- native/app/inventory/logic/Sockets.ts | 1 - native/app/inventory/logic/Transfer.ts | 2 +- native/app/inventory/pages/details/ScreenInfo.tsx | 2 +- 5 files changed, 7 insertions(+), 21 deletions(-) diff --git a/minifier/next_gen.ts b/minifier/next_gen.ts index d946a801..237c7c13 100644 --- a/minifier/next_gen.ts +++ b/minifier/next_gen.ts @@ -228,17 +228,6 @@ function createMiniDefinition(jsonData: JsonData, uniqueKey: string): ProcessedD Icons: new Map(), }; - // Send a repeat string and get a index value back - // function getRepeatStringIndexMap(name: RepeatStringsName, s: string): number { - // const index = repeatStrings[name].indexOf(s); - // if (index === -1) { - // repeatStrings[name].push(s); - // return getRepeatStringIndexMap(name, s); - // } - - // return index; - // } - function getRepeatStringIndexMap(name: RepeatStringsName, s: string): number { if (!repeatStringsMap[name].has(s)) { repeatStringsMap[name].set(s, repeatStringsMap[name].size); diff --git a/native/app/Root.tsx b/native/app/Root.tsx index c9cb0e04..10fc1328 100644 --- a/native/app/Root.tsx +++ b/native/app/Root.tsx @@ -2,15 +2,11 @@ import * as SplashScreen from "expo-splash-screen"; import { NavigationContainer, type NavigationContainerRef, type Theme } from "@react-navigation/native"; import { useEffect, useRef } from "react"; import { StatusBar, useWindowDimensions, Platform, Appearance } from "react-native"; -import { enableFreeze } from "react-native-screens"; +import { enableFreeze, enableScreens } from "react-native-screens"; import { object, parse, string } from "valibot"; import Toast from "react-native-toast-message"; import { GestureHandlerRootView } from "react-native-gesture-handler"; import { PortalHost } from "@rn-primitives/portal"; -import { enableScreens } from "react-native-screens"; - -// Enable screens for better performance -enableScreens(); import { BUNGIE_MANIFEST_URL, CUSTOM_MANIFEST_URL, getFullProfile } from "@/app/bungie/BungieApi.ts"; import { getJsonBlob } from "@/app/utilities/Helpers.ts"; @@ -21,13 +17,15 @@ import App from "@/app/App"; // Do not use the file extension or the web version import "@/global.css"; import { removeAsyncStorageItem } from "@/app/store/DefinitionsSlice.ts"; +// Enable screens for better performance +enableScreens(); +enableFreeze(true); + SplashScreen.preventAutoHideAsync(); if (Platform.OS !== "web") { Appearance.setColorScheme("dark"); } -enableFreeze(true); - let customDownloadAttempts = 0; async function getCustomItemDefinition() { try { diff --git a/native/app/inventory/logic/Sockets.ts b/native/app/inventory/logic/Sockets.ts index 7aa559e8..ec1e360d 100644 --- a/native/app/inventory/logic/Sockets.ts +++ b/native/app/inventory/logic/Sockets.ts @@ -136,7 +136,6 @@ export function createSockets(destinyItem: DestinyItem): Sockets | null { const sockets = expandAndCreateSockets(destinyItem.itemHash); if (!sockets) { - // console.error("Failed to create sockets for item", destinyItem.itemHash); return null; } diff --git a/native/app/inventory/logic/Transfer.ts b/native/app/inventory/logic/Transfer.ts index be6883be..19e5750e 100644 --- a/native/app/inventory/logic/Transfer.ts +++ b/native/app/inventory/logic/Transfer.ts @@ -437,7 +437,7 @@ async function moveItem(transferItem: TransferItem): Promise<[JSON, DestinyItem] } let toVault = false; - let characterId = "" as CharacterId; + let characterId: CharacterId; if (transferItem.destinyItem.characterId !== VAULT_CHARACTER_ID) { if (GLOBAL_INVENTORY_NAMES.includes(transferItem.destinyItem.characterId)) { diff --git a/native/app/inventory/pages/details/ScreenInfo.tsx b/native/app/inventory/pages/details/ScreenInfo.tsx index bea8a5d9..7bb44add 100644 --- a/native/app/inventory/pages/details/ScreenInfo.tsx +++ b/native/app/inventory/pages/details/ScreenInfo.tsx @@ -129,7 +129,7 @@ function getPrimaryStatLabel(destinyItem: DestinyItem): string { return ""; } -function PrimaryStatUI({ destinyItem }: { destinyItem: DestinyItem }) { +function PrimaryStatUI({ destinyItem }: { readonly destinyItem: DestinyItem }) { "use memo"; const POWER_NAME = getPrimaryStatLabel(destinyItem);