From 6ec47df67fb592669c19de139094b4add025b913 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Mon, 15 Feb 2021 10:06:17 +0100 Subject: [PATCH] Improve code quality --- server/sonar-web/src/main/js/api/rules.ts | 33 +++++++++++++++++-- .../components/CopyQualityGateForm.tsx | 4 +-- server/sonar-web/src/main/js/types/issues.ts | 14 ++++---- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/server/sonar-web/src/main/js/api/rules.ts b/server/sonar-web/src/main/js/api/rules.ts index 2f6beb58407..3dd2448d96e 100644 --- a/server/sonar-web/src/main/js/api/rules.ts +++ b/server/sonar-web/src/main/js/api/rules.ts @@ -25,12 +25,39 @@ export function getRulesApp(): Promise { return getJSON('/api/rules/app').catch(throwGlobalError); } -export function searchRules(data: { [x: string]: any }): Promise { +export function searchRules(data: { + activation?: boolean | string; + active_severities?: string; + asc?: boolean | string; + available_since?: string; + cwe?: string; + f?: string; + facets?: string; + include_external?: boolean | string; + inheritance?: string; + is_template?: boolean | string; + languages?: string; + owaspTop10?: string; + p?: number; + ps?: number; + q?: string; + qprofile?: string; + repositories?: string; + rule_key?: string; + s?: string; + sansTop25?: string; + severities?: string; + sonarsourceSecurity?: string; + statuses?: string; + tags?: string; + template_key?: string; + types?: string; +}): Promise { return getJSON('/api/rules/search', data).catch(throwGlobalError); } -export function takeFacet(response: any, property: string) { - const facet = response.facets.find((facet: any) => facet.property === property); +export function takeFacet(response: SearchRulesResponse, property: string) { + const facet = response.facets?.find(f => f.property === property); return facet ? facet.values : []; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx b/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx index 4c72bb926a2..d8d950846bc 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx +++ b/server/sonar-web/src/main/js/apps/quality-gates/components/CopyQualityGateForm.tsx @@ -53,9 +53,9 @@ export class CopyQualityGateForm extends React.PureComponent { return undefined; } - return copyQualityGate({ id: qualityGate.id, name }).then(qualityGate => { + return copyQualityGate({ id: qualityGate.id, name }).then(newQualityGate => { this.props.onCopy(); - this.props.router.push(getQualityGateUrl(String(qualityGate.id))); + this.props.router.push(getQualityGateUrl(String(newQualityGate.id))); }); }; diff --git a/server/sonar-web/src/main/js/types/issues.ts b/server/sonar-web/src/main/js/types/issues.ts index 0e137ef4059..b7252e20dad 100644 --- a/server/sonar-web/src/main/js/types/issues.ts +++ b/server/sonar-web/src/main/js/types/issues.ts @@ -30,16 +30,15 @@ export enum IssueScope { } interface Comment { + createdAt: string; + htmlText: string; + key: string; login: string; - [x: string]: any; + markdown: string; + updatable: boolean; } -interface IssueBase { - severity: string; - [x: string]: any; -} - -export interface RawIssue extends IssueBase { +export interface RawIssue { assignee?: string; author?: string; comments?: Array; @@ -52,6 +51,7 @@ export interface RawIssue extends IssueBase { line?: number; project: string; rule: string; + severity: string; status: string; subProject?: string; textRange?: T.TextRange; -- 2.39.5