From: 7PH Date: Tue, 29 Aug 2023 12:34:05 +0000 (+0200) Subject: SONAR-20023 Keep support for the old severity filter if provided in the URL X-Git-Tag: 10.2.0.77647~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a071713469d8ab358099b913a214aab0aa27cd4a;p=sonarqube.git SONAR-20023 Keep support for the old severity filter if provided in the URL --- diff --git a/server/sonar-web/src/main/js/apps/coding-rules/query.ts b/server/sonar-web/src/main/js/apps/coding-rules/query.ts index eb31bc35298..60385450920 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/query.ts +++ b/server/sonar-web/src/main/js/apps/coding-rules/query.ts @@ -24,7 +24,6 @@ import { parseAsOptionalBoolean, parseAsOptionalString, parseAsString, - parseImpactSeverityQuery, queriesEqual, serializeDateShort, serializeOptionalBoolean, @@ -93,7 +92,7 @@ export function parseQuery(query: RawQuery): Query { ), compareToProfile: parseAsOptionalString(query.compareToProfile), cwe: parseAsArray(query.cwe, parseAsString), - impactSeverities: parseImpactSeverityQuery(query.impactSeverities, query.severities), + impactSeverities: parseAsArray(query.impactSeverities, parseAsString), impactSoftwareQualities: parseAsArray( query.impactSoftwareQualities, parseAsString @@ -133,7 +132,7 @@ export function serializeQuery(query: Query): RawQuery { qprofile: serializeString(query.profile), repositories: serializeStringArray(query.repositories), rule_key: serializeString(query.ruleKey), - severities: undefined, + severities: serializeStringArray(query.severities), sonarsourceSecurity: serializeStringArray(query.sonarsourceSecurity), statuses: serializeStringArray(query.statuses), tags: serializeStringArray(query.tags), diff --git a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts index 15c4260b27c..e366cd670d5 100644 --- a/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts @@ -102,6 +102,7 @@ describe('serialize/deserialize', () => { s: 'rules', scopes: 'a,b', inNewCodePeriod: 'true', + severities: 'a,b', sonarsourceSecurity: 'a,b', statuses: 'a,b', tags: 'a,b', @@ -133,11 +134,7 @@ describe('serialize/deserialize', () => { cwe: [], directories: [], files: [], - impactSeverities: [ - SoftwareImpactSeverity.Low, - SoftwareImpactSeverity.High, - SoftwareImpactSeverity.Medium, - ], + impactSeverities: [SoftwareImpactSeverity.Low], impactSoftwareQualities: [SoftwareQuality.Maintainability], inNewCodePeriod: false, issues: [], @@ -153,7 +150,7 @@ describe('serialize/deserialize', () => { resolved: true, rules: [], scopes: [], - severities: [], + severities: ['CRITICAL', 'MAJOR'], sonarsourceSecurity: [], sort: '', statuses: [], diff --git a/server/sonar-web/src/main/js/apps/issues/utils.ts b/server/sonar-web/src/main/js/apps/issues/utils.ts index f3f9c40661b..81f6e8bf764 100644 --- a/server/sonar-web/src/main/js/apps/issues/utils.ts +++ b/server/sonar-web/src/main/js/apps/issues/utils.ts @@ -26,7 +26,6 @@ import { parseAsBoolean, parseAsDate, parseAsString, - parseImpactSeverityQuery, queriesEqual, serializeDateShort, serializeString, @@ -106,7 +105,7 @@ export function parseQuery(query: RawQuery): Query { cwe: parseAsArray(query.cwe, parseAsString), directories: parseAsArray(query.directories, parseAsString), files: parseAsArray(query.files, parseAsString), - impactSeverities: parseImpactSeverityQuery(query.impactSeverities, query.severities), + impactSeverities: parseAsArray(query.impactSeverities, parseAsString), impactSoftwareQualities: parseAsArray( query.impactSoftwareQualities, parseAsString @@ -125,7 +124,7 @@ export function parseQuery(query: RawQuery): Query { resolved: parseAsBoolean(query.resolved), rules: parseAsArray(query.rules, parseAsString), scopes: parseAsArray(query.scopes, parseAsString), - severities: [], + severities: parseAsArray(query.severities, parseAsString), sonarsourceSecurity: parseAsArray(query.sonarsourceSecurity, parseAsString), sort: parseAsSort(query.s), statuses: parseAsArray(query.statuses, parseAsString), @@ -173,7 +172,7 @@ export function serializeQuery(query: Query): RawQuery { rules: serializeStringArray(query.rules), s: serializeString(query.sort), scopes: serializeStringArray(query.scopes), - severities: undefined, + severities: serializeStringArray(query.severities), impactSeverities: serializeStringArray(query.impactSeverities), impactSoftwareQualities: serializeStringArray(query.impactSoftwareQualities), inNewCodePeriod: query.inNewCodePeriod ? 'true' : undefined, diff --git a/server/sonar-web/src/main/js/helpers/query.ts b/server/sonar-web/src/main/js/helpers/query.ts index 97238fc4ab8..37ced126f60 100644 --- a/server/sonar-web/src/main/js/helpers/query.ts +++ b/server/sonar-web/src/main/js/helpers/query.ts @@ -17,8 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { compact, isEqual, isNil, omitBy, uniq } from 'lodash'; -import { SoftwareImpactSeverity } from '../types/clean-code-taxonomy'; +import { isEqual, isNil, omitBy } from 'lodash'; import { RawQuery } from '../types/types'; import { isValidDate, parseDate, toISO8601WithOffsetString, toShortISO8601String } from './dates'; @@ -126,26 +125,3 @@ export function serializeOptionalBoolean(value: boolean | undefined): string | u } return undefined; } - -export function parseImpactSeverityQuery( - newSeverities: string, - oldSeverities?: string -): SoftwareImpactSeverity[] { - const OLD_TO_NEW_MAPPER = { - BLOCKER: SoftwareImpactSeverity.High, - CRITICAL: SoftwareImpactSeverity.High, - MAJOR: SoftwareImpactSeverity.Medium, - MINOR: SoftwareImpactSeverity.Low, - INFO: SoftwareImpactSeverity.Low, - }; - - // Merging new and old severities includes mapping for old to new - return compact( - uniq([ - ...parseAsArray(newSeverities, parseAsString), - ...parseAsArray(oldSeverities, parseAsString).map( - (oldSeverity: string) => OLD_TO_NEW_MAPPER[oldSeverity as keyof typeof OLD_TO_NEW_MAPPER] - ), - ]) - ); -}