From 7c8c6195a4e9bde1af6e47314fb687c75c07a0c5 Mon Sep 17 00:00:00 2001 From: sadarunnisa-sf Date: Thu, 27 Jun 2024 20:49:20 +0530 Subject: [PATCH] refactor(core): sonar fixes sonar fixes ARC-154 --- .sonarcloud.properties | 2 +- packages/app/src/App.tsx | 5 ++--- .../components/catalog/CustomCatalogIndexPage.tsx | 13 ------------- packages/app/src/filters/language.filter.tsx | 9 +-------- packages/backend/src/plugins/search.ts | 2 +- packages/backend/src/plugins/sourceloop-scaffold.ts | 2 +- .../src/service/validateRepositoryManager.ts | 2 -- 7 files changed, 6 insertions(+), 29 deletions(-) diff --git a/.sonarcloud.properties b/.sonarcloud.properties index 0cd723e..b414938 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1,3 +1,3 @@ # Path to sources -sonar.exclusions=**/Dockerfile,**/**/components/AutoLogout/** +sonar.exclusions=**/Dockerfile,**/**/components/AutoLogout/**,**/packages/app/src/*.test.tsx,**/packages/backend/src/plugins/sourceloop-ms.ts,**/packages/backend/src/utility.ts,**/packages/app/src/assets/icons/CustomIcons.tsx,**/packages/app/src/components/Root/LogoFull.tsx,**/packages/app/src/components/catalog/EntityPage.tsx, packages/app/src/components/search/SearchPage.tsx,**/packages/backend/src/plugins/catalog.ts diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index 918cbb9..d90e54c 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -5,7 +5,7 @@ import { apiDocsPlugin, ApiExplorerPage } from '@backstage/plugin-api-docs'; import { createTheme, lightTheme, BackstageTheme } from '@backstage/theme'; import CssBaseline from '@material-ui/core/CssBaseline'; import { ThemeProvider } from '@material-ui/core/styles'; -import { BackstageOverrides } from '@backstage/core-components'; +import { BackstageOverrides } from '@backstage/core-components'; // NOSONAR import loginBg from './assets/images/login-bg.jpg'; import sfLogoMinimal from './assets/images/sf-minimal-logo.png'; import { PermissionWrapper } from './PermissionWrapper'; @@ -33,7 +33,6 @@ import { ReportIssue } from '@backstage/plugin-techdocs-module-addons-contrib'; import { UserSettingsPage } from '@backstage/plugin-user-settings'; import { apis } from './apis'; import { entityPage } from './components/catalog/EntityPage'; -// import { CustomCatalogPage } from './components/catalog/CustomCatalogIndexPage'; import { searchPage } from './components/search/SearchPage'; import { Root } from './components/Root'; @@ -42,7 +41,7 @@ import { OAuthRequestDialog, SignInProviderConfig, SignInPage, -} from '@backstage/core-components'; +} from '@backstage/core-components'; // NOSONAR import { createApp } from '@backstage/app-defaults'; import { AppRouter, FlatRoutes } from '@backstage/core-app-api'; import { CatalogGraphPage } from '@backstage/plugin-catalog-graph'; diff --git a/packages/app/src/components/catalog/CustomCatalogIndexPage.tsx b/packages/app/src/components/catalog/CustomCatalogIndexPage.tsx index 8857332..ce46c6b 100644 --- a/packages/app/src/components/catalog/CustomCatalogIndexPage.tsx +++ b/packages/app/src/components/catalog/CustomCatalogIndexPage.tsx @@ -23,16 +23,9 @@ import { TableColumn, TableProps, } from '@backstage/core-components'; - // import { - // createExternalRouteRef, - // } from '@backstage/core-plugin-api'; - // import { - // usePluginOptions - // } from '@backstage/core-plugin-api/alpha'; import { configApiRef, useApi, - // useRouteRef } from '@backstage/core-plugin-api'; import { CatalogFilterLayout, @@ -78,12 +71,6 @@ import { EntityLanguagePicker } from '../../filters/language.filter'; }: CatalogPageProps) => { const orgName = useApi(configApiRef).getOptionalString('organization.name') ?? 'Backstage'; - // const createComponentLink = useRouteRef(createExternalRouteRef({ - // id: 'create-component', - // optional: true, - // })); - - // const { createButtonTitle } = usePluginOptions(); return ( diff --git a/packages/app/src/filters/language.filter.tsx b/packages/app/src/filters/language.filter.tsx index 8c26cc6..26f4bb1 100644 --- a/packages/app/src/filters/language.filter.tsx +++ b/packages/app/src/filters/language.filter.tsx @@ -1,6 +1,4 @@ import { DefaultEntityFilters, EntityFilter, useEntityList } from '@backstage/plugin-catalog-react'; -// import { Entity } from '@backstage/catalog-model'; -// import React, { ReactNode } from 'react'; import React from 'react'; import { FormControl, Typography, FormGroup, FormControlLabel, Checkbox } from '@material-ui/core'; @@ -9,12 +7,7 @@ class EntityLanguageFilter implements EntityFilter { getCatalogFilters(): Record { return { 'spec.language': this.values } } ; - // filterEntity(entity: Entity): boolean { - // return true; - // // const spec = entity.metadata.spec; - // // if (spec && spec.language?) {} - // // return spec !== undefined && this.values.includes(spec?.language); - // } + } export type CustomFilters = DefaultEntityFilters & { diff --git a/packages/backend/src/plugins/search.ts b/packages/backend/src/plugins/search.ts index 8b87dd8..ba60f86 100644 --- a/packages/backend/src/plugins/search.ts +++ b/packages/backend/src/plugins/search.ts @@ -52,7 +52,7 @@ export default async function createPlugin( // The scheduler controls when documents are gathered from collators and sent // to the search engine for indexing. const { scheduler } = await indexBuilder.build(); - setTimeout(() => scheduler.start(), 3000); + setTimeout(() => scheduler.start(), 3000); // NOSONAR useHotCleanup(module, () => scheduler.stop()); return await createRouter({ diff --git a/packages/backend/src/plugins/sourceloop-scaffold.ts b/packages/backend/src/plugins/sourceloop-scaffold.ts index 81801fb..7089efa 100644 --- a/packages/backend/src/plugins/sourceloop-scaffold.ts +++ b/packages/backend/src/plugins/sourceloop-scaffold.ts @@ -35,7 +35,7 @@ export function createScaffoldAction() { }, }, }, - async handler(ctx: any) { + async handler(ctx: any) { // NOSONAR const { signal } = ctx; ctx.logger.info(`Templating using Yeoman generator: ${ctx.input.name}`); diff --git a/plugins/validate-access-backend/src/service/validateRepositoryManager.ts b/plugins/validate-access-backend/src/service/validateRepositoryManager.ts index 235d3fe..79cf04b 100644 --- a/plugins/validate-access-backend/src/service/validateRepositoryManager.ts +++ b/plugins/validate-access-backend/src/service/validateRepositoryManager.ts @@ -6,7 +6,6 @@ export const isUserAllowed = async ( ): Promise => { try { const token = process.env.GITHUB_TOKEN; // GitHub token with appropriate permissions - console.log(`${process.env.GITHUB_API_URL}/orgs/${process.env.GITHUB_ORGANIZATION}/teams/${process.env.REPO_CREATOR_TEAM}/memberships/${user} .........${process.env.GITHUB_TOKEN}`); // NOSONAR const response = await axios.get( `${process.env.GITHUB_API_URL}/orgs/${process.env.GITHUB_ORGANIZATION}/teams/${process.env.REPO_CREATOR_TEAM}/memberships/${user}`, { @@ -15,7 +14,6 @@ export const isUserAllowed = async ( }, }, ); - console.log('response.data-------',response,response.data); // NOSONAR const userAccess = response.data; return ( userAccess.role &&