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 --- .eslintrc.js | 2 +- .github/workflows/builds.yml | 4 ++-- build-helpers/notarize.js | 7 ++++++- 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 +++++---- src/containers/auth/SetupAssistantScreen.tsx | 2 +- src/containers/layout/AppLayoutContainer.tsx | 4 ++-- src/containers/settings/EditServiceScreen.tsx | 6 +++--- src/containers/settings/ServicesScreen.tsx | 8 ++++---- src/features/appearance/index.ts | 6 ------ src/features/todos/components/TodosWebview.tsx | 2 +- src/features/todos/containers/TodosScreen.tsx | 2 +- src/features/todos/store.ts | 2 +- src/features/webControls/components/WebControls.tsx | 13 +++++++------ .../workspaces/components/WorkspaceDrawerItem.tsx | 9 +++++---- src/features/workspaces/components/WorkspaceItem.tsx | 2 +- .../components/WorkspaceSwitchingIndicator.tsx | 9 +++++---- .../workspaces/components/WorkspacesDashboard.tsx | 2 +- src/features/workspaces/store.ts | 4 ++-- src/helpers/userAgent-helpers.ts | 2 +- src/index.ts | 1 + src/jsUtils.ts | 2 +- src/models/Recipe.ts | 4 ++-- 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 +- 51 files changed, 121 insertions(+), 116 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 54ae4c8ad..e89b5a618 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -69,7 +69,7 @@ module.exports = { 'import/no-unresolved': 0, 'import/prefer-default-export': 0, // eslint-plugin-react - // TODO - [TS DEBT] should remove below config once application converted to TS + // TODO: [TS DEBT] should remove below config once application converted to TS 'react/default-props-match-prop-types': 0, 'react/require-default-props': 0, '@typescript-eslint/no-useless-constructor': 0, diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 86e6a1e4a..09eb68fde 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -297,7 +297,7 @@ jobs: env: GH_TOKEN: ${{ secrets.FERDIUM_PUBLISH_TOKEN }} CSC_IDENTITY_AUTO_DISCOVERY: false - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_LOGIN }} # Note: Login no longer required https://forum.snapcraft.io/t/snapcraft-authentication-options/30473/21 + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_LOGIN }} # Note: Login no longer required https://forum.snapcraft.io/t/snapcraft-authentication-options/30473/21 run: | sudo snap install snapcraft --channel=7.x/stable --classic pnpm build --publish always -c.snap.publish.repo=$SNAP_PUBLISH_REPO -c.snap.publish.channels=$SNAP_PUBLISH_CHANNEL @@ -355,7 +355,7 @@ jobs: node-version-file: ".nvmrc" - name: Install pnpm run: npm i -gf "pnpm@$(node -p 'require(\"./package.json\").engines.pnpm')" && pnpm -v - #TODO - Remove this once https://github.com/electron-userland/electron-builder/issues/6933#issuecomment-1213438889 is resolved + # TODO: Remove this once https://github.com/electron-userland/electron-builder/issues/6933#issuecomment-1213438889 is resolved - name: Tweak pnpm.cjs run: sed -i 's/\/usr\/bin\/env node/node/g' /c/npm/prefix/node_modules/pnpm/bin/pnpm.cjs shell: bash diff --git a/build-helpers/notarize.js b/build-helpers/notarize.js index a067a9882..32faa97b8 100644 --- a/build-helpers/notarize.js +++ b/build-helpers/notarize.js @@ -1,6 +1,11 @@ exports.default = async function notarizing(context) { const { electronPlatformName, appOutDir } = context; - if (electronPlatformName !== 'darwin' || process.env.CSC_IDENTITY_AUTO_DISCOVERY === 'false' || (process.env.GIT_BRANCH_NAME !== 'release' && process.env.GIT_BRANCH_NAME !== 'nightly')) { + if ( + electronPlatformName !== 'darwin' || + process.env.CSC_IDENTITY_AUTO_DISCOVERY === 'false' || + (process.env.GIT_BRANCH_NAME !== 'release' && + process.env.GIT_BRANCH_NAME !== 'nightly') + ) { return; } 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 {