From 99ca310c73024b51fed1f3077375eed7827f2c20 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sun, 28 May 2023 13:48:21 +0530 Subject: Fix issues reported by sonarqube linter --- src/stores/AppStore.ts | 4 ++-- src/stores/GlobalErrorStore.ts | 2 +- src/stores/ServicesStore.ts | 4 ++-- src/stores/UserStore.ts | 2 +- src/stores/index.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/stores') diff --git a/src/stores/AppStore.ts b/src/stores/AppStore.ts index 18b38799e..82591a2a4 100644 --- a/src/stores/AppStore.ts +++ b/src/stores/AppStore.ts @@ -212,7 +212,7 @@ export default class AppStore extends TypedStore { } if (data.error) { - if (data.error.message && data.error.message.startsWith('404')) { + if (data.error.message?.startsWith('404')) { this.updateStatus = this.updateStatusTypes.NOT_AVAILABLE; console.warn( 'Updater warning: there seems to be unpublished pre-release(s) available on GitHub', @@ -350,7 +350,7 @@ export default class AppStore extends TypedStore { if (this.stores.settings.all.app.isAppMuted) return; // TODO: is there a simple way to use blobs for notifications without storing them on disk? - if (options.icon && options.icon.startsWith('blob:')) { + if (options.icon?.startsWith('blob:')) { delete options.icon; } diff --git a/src/stores/GlobalErrorStore.ts b/src/stores/GlobalErrorStore.ts index be86563d0..8547fec72 100644 --- a/src/stores/GlobalErrorStore.ts +++ b/src/stores/GlobalErrorStore.ts @@ -86,7 +86,7 @@ export default class GlobalErrorStore extends TypedStore { if (request.isError) { this.error = request.error; - if (request.error && request.error.json) { + if (request.error?.json) { try { this.response = await request.error.json(); } catch { diff --git a/src/stores/ServicesStore.ts b/src/stores/ServicesStore.ts index 9c15d3a07..44f8b277c 100644 --- a/src/stores/ServicesStore.ts +++ b/src/stores/ServicesStore.ts @@ -425,12 +425,12 @@ export default class ServicesStore extends TypedStore { return ( this.allDisplayed.find( service => service.isTodosService && service.isEnabled, - ) || false + ) ?? false ); } @computed get isTodosServiceActive() { - return this.active && this.active.isTodosService; + return this.active?.isTodosService; } // TODO: This can actually return undefined as well diff --git a/src/stores/UserStore.ts b/src/stores/UserStore.ts index 6c8f8f20b..7ba8f4222 100644 --- a/src/stores/UserStore.ts +++ b/src/stores/UserStore.ts @@ -209,7 +209,7 @@ export default class UserStore extends TypedStore { plan, currency, }): Promise { - // TODO - [TS DEBT] Need to find a way proper to implement promise's then and catch in request class + // TODO: [TS DEBT] Need to find a way proper to implement promise's then and catch in request class // @ts-ignore const authToken = await this.signupRequest.execute({ firstname, diff --git a/src/stores/index.ts b/src/stores/index.ts index 8836f2892..f9927d9a3 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -57,7 +57,7 @@ export default ( // Initialize all stores for (const name of Object.keys(stores)) { - if (stores[name] && stores[name].initialize) { + if (stores[name]?.initialize) { stores[name].initialize(); } } -- cgit v1.2.3-54-g00ecf