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/components/auth/Invite.tsx | 2 +- src/components/auth/SetupAssistant.tsx | 2 +- src/components/layout/AppLayout.tsx | 11 ++++------- .../services/content/ConnectionLostBanner.tsx | 9 +++++---- src/components/services/content/ServiceView.tsx | 10 +++++----- src/components/services/content/ServiceWebview.tsx | 6 +++--- src/components/services/content/Services.tsx | 12 ++++++------ .../settings/navigation/SettingsNavigation.tsx | 2 +- src/components/settings/services/ServiceItem.tsx | 2 +- src/components/settings/services/ServicesDashboard.tsx | 6 +++--- src/components/settings/settings/EditSettingsForm.tsx | 9 ++++++--- src/components/settings/team/TeamDashboard.tsx | 2 ++ src/components/ui/AppLoader/styles.ts | 9 +++++---- src/components/ui/Infobox.tsx | 2 +- src/components/ui/Loader.tsx | 2 +- src/components/ui/Radio.tsx | 2 +- src/components/ui/Select.tsx | 4 ++-- src/components/ui/ServiceIcon.tsx | 2 +- src/components/ui/Slider.tsx | 2 +- src/components/ui/StatusBarTargetUrl.tsx | 2 +- src/components/ui/infobox/index.tsx | 2 +- src/components/ui/input/index.tsx | 2 +- src/components/ui/select/index.tsx | 17 +++++++---------- src/components/ui/textarea/index.tsx | 2 +- src/components/ui/toggle/index.tsx | 9 +++++---- 25 files changed, 66 insertions(+), 64 deletions(-) (limited to 'src/components') diff --git a/src/components/auth/Invite.tsx b/src/components/auth/Invite.tsx index cebef9365..4f2cb19fe 100644 --- a/src/components/auth/Invite.tsx +++ b/src/components/auth/Invite.tsx @@ -86,7 +86,7 @@ class Invite extends Component { }, }, }), - // TODO - [TS DEBT] need to fix this type once mobx-react-form is updated to next version + // TODO: [TS DEBT] need to fix this type once mobx-react-form is updated to next version ] as any, }, }); diff --git a/src/components/auth/SetupAssistant.tsx b/src/components/auth/SetupAssistant.tsx index c5fb79919..fdcbba45e 100644 --- a/src/components/auth/SetupAssistant.tsx +++ b/src/components/auth/SetupAssistant.tsx @@ -135,7 +135,7 @@ const styles = theme => ({ interface IProps extends WithStylesProps, WrappedComponentProps { onSubmit: (...args: any[]) => void; isInviteSuccessful?: boolean; - services: any; // TODO - [TS DEBT] check legacy services type + services: any; // TODO: [TS DEBT] check legacy services type isSettingUpServices: boolean; } diff --git a/src/components/layout/AppLayout.tsx b/src/components/layout/AppLayout.tsx index 86b4e787e..97795212a 100644 --- a/src/components/layout/AppLayout.tsx +++ b/src/components/layout/AppLayout.tsx @@ -14,7 +14,6 @@ import { Component as PublishDebugInfo } from '../../features/publishDebugInfo'; import ErrorBoundary from '../util/ErrorBoundary'; import { updateVersionParse } from '../../helpers/update-helpers'; -// import globalMessages from '../../i18n/globalMessages'; import { isMac, isWindows } from '../../environment'; import WorkspaceSwitchingIndicator from '../../features/workspaces/components/WorkspaceSwitchingIndicator'; import { workspaceStore } from '../../features/workspaces'; @@ -45,13 +44,11 @@ const messages = defineMessages({ }, }); -let transition = 'none'; +const transition = window?.matchMedia('(prefers-reduced-motion: no-preference)') + ? 'transform 0.5s ease' + : 'none'; -if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) { - transition = 'transform 0.5s ease'; -} - -const styles = theme => ({ +const styles = (theme: { workspaces: { drawer: { width: any } } }) => ({ appContent: { // width: `calc(100% + ${theme.workspaces.drawer.width}px)`, width: '100%', diff --git a/src/components/services/content/ConnectionLostBanner.tsx b/src/components/services/content/ConnectionLostBanner.tsx index 88731f3b9..7040337f0 100644 --- a/src/components/services/content/ConnectionLostBanner.tsx +++ b/src/components/services/content/ConnectionLostBanner.tsx @@ -21,10 +21,11 @@ const messages = defineMessages({ }, }); -const buttonTransition = - window && window.matchMedia('(prefers-reduced-motion: no-preference)') - ? 'opacity 0.25s' - : 'none'; +const buttonTransition = window?.matchMedia( + '(prefers-reduced-motion: no-preference)', +) + ? 'opacity 0.25s' + : 'none'; const styles = theme => ({ root: { diff --git a/src/components/services/content/ServiceView.tsx b/src/components/services/content/ServiceView.tsx index 0754bccc5..19dcdd07a 100644 --- a/src/components/services/content/ServiceView.tsx +++ b/src/components/services/content/ServiceView.tsx @@ -21,7 +21,7 @@ interface IProps { reload: () => void; edit: () => void; enable: () => void; - // isActive?: boolean; // TODO - [TECH DEBT][PROP NOT USED IN COMPONENT] check it + // isActive?: boolean; // TODO: [TECH DEBT][PROP NOT USED IN COMPONENT] check it stores?: RealStores; isSpellcheckerEnabled: boolean; } @@ -35,7 +35,7 @@ interface IState { @inject('stores', 'actions') @observer class ServiceView extends Component { - // hibernationTimer = null; // TODO - [TS DEBT] class property not reassigned, need to find its purpose + // hibernationTimer = null; // TODO: [TS DEBT] class property not reassigned, need to find its purpose autorunDisposer: IReactionDisposer | undefined; @@ -65,7 +65,7 @@ class ServiceView extends Component { componentWillUnmount() { this.autorunDisposer!(); clearTimeout(this.forceRepaintTimeout!); - // clearTimeout(this.hibernationTimer); // TODO - [TS DEBT] class property not reassigned, need to find its purpose + // clearTimeout(this.hibernationTimer); // TODO: [TS DEBT] class property not reassigned, need to find its purpose } render() { @@ -111,7 +111,7 @@ class ServiceView extends Component { {service.hasCrashed && ( )} @@ -177,7 +177,7 @@ class ServiceView extends Component { {service.isActive && ( )} diff --git a/src/components/services/content/ServiceWebview.tsx b/src/components/services/content/ServiceWebview.tsx index ac8d1ea66..008e1b227 100644 --- a/src/components/services/content/ServiceWebview.tsx +++ b/src/components/services/content/ServiceWebview.tsx @@ -32,7 +32,7 @@ class ServiceWebview extends Component { reaction( () => this.webview, () => { - if (this.webview && this.webview.view) { + if (this.webview?.view) { this.webview.view.addEventListener('console-message', e => { debug('Service logged a message:', e.message); }); @@ -97,7 +97,7 @@ class ServiceWebview extends Component { { this._setWebview(webview); - if (webview && webview.view) { + if (webview?.view) { webview.view.addEventListener( 'did-stop-loading', this.refocusWebview, @@ -122,7 +122,7 @@ class ServiceWebview extends Component { }); }, 0); }} - // onUpdateTargetUrl={this.updateTargetUrl} // TODO - [TS DEBT] need to check where its from + // onUpdateTargetUrl={this.updateTargetUrl} // TODO: [TS DEBT] need to check where its from useragent={service.userAgent} disablewebsecurity={ service.recipe.disablewebsecurity ? true : undefined diff --git a/src/components/services/content/Services.tsx b/src/components/services/content/Services.tsx index fa26edaa6..5766e0d75 100644 --- a/src/components/services/content/Services.tsx +++ b/src/components/services/content/Services.tsx @@ -42,8 +42,8 @@ interface IProps extends WrappedComponentProps, WithStylesProps { services?: Service[]; setWebviewReference: () => void; detachService: () => void; - // handleIPCMessage: () => void; // TODO - [TECH DEBT] later check it - // openWindow: () => void; // TODO - [TECH DEBT] later check it + // handleIPCMessage: () => void; // TODO: [TECH DEBT] later check it + // openWindow: () => void; // TODO: [TECH DEBT] later check it reload: (options: { serviceId: string }) => void; openSettings: (options: { path: string }) => void; update: (options: { @@ -88,10 +88,10 @@ class Services extends Component { render(): ReactElement { const { services = [], - // handleIPCMessage, // TODO - [TECH DEBT] later check it + // handleIPCMessage, // TODO: [TECH DEBT] later check it setWebviewReference, detachService, - // openWindow, // TODO - [TECH DEBT] later check it + // openWindow, // TODO: [TECH DEBT] later check it reload, openSettings, update, @@ -136,10 +136,10 @@ class Services extends Component { reload({ serviceId: service.id })} edit={() => openSettings({ path: `services/edit/${service.id}` })} enable={() => diff --git a/src/components/settings/navigation/SettingsNavigation.tsx b/src/components/settings/navigation/SettingsNavigation.tsx index 4e2c7f410..6ffaa411f 100644 --- a/src/components/settings/navigation/SettingsNavigation.tsx +++ b/src/components/settings/navigation/SettingsNavigation.tsx @@ -187,7 +187,7 @@ class SettingsNavigation extends Component {