]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20023 Keep support for the old severity filter if provided in the URL
author7PH <benjamin.raymond@sonarsource.com>
Tue, 29 Aug 2023 12:34:05 +0000 (14:34 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 30 Aug 2023 20:03:06 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/coding-rules/query.ts
server/sonar-web/src/main/js/apps/issues/__tests__/utils-test.ts
server/sonar-web/src/main/js/apps/issues/utils.ts
server/sonar-web/src/main/js/helpers/query.ts

index eb31bc35298c637eed59a775b76c8cddd645b08c..603854509206f1924af3530d7b8d8a9fd8397da1 100644 (file)
@@ -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<SoftwareImpactSeverity>(query.impactSeverities, parseAsString),
     impactSoftwareQualities: parseAsArray<SoftwareQuality>(
       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),
index 15c4260b27cdc1b2d1b77585947ad4d73ac445b0..e366cd670d52ecf75bfbded7d5f0de04f202bd00 100644 (file)
@@ -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: [],
index f3f9c40661b779b7141d120cc08109b424879053..81f6e8bf76452bf2f77dfa872a0d8e175f757994 100644 (file)
@@ -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<SoftwareImpactSeverity>(query.impactSeverities, parseAsString),
     impactSoftwareQualities: parseAsArray<SoftwareQuality>(
       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,
index 97238fc4ab807fc4b78565bad6e421c8c6169e76..37ced126f60bd1df7a54e6157852f9fb26c8b55c 100644 (file)
@@ -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<SoftwareImpactSeverity>(newSeverities, parseAsString),
-      ...parseAsArray(oldSeverities, parseAsString).map(
-        (oldSeverity: string) => OLD_TO_NEW_MAPPER[oldSeverity as keyof typeof OLD_TO_NEW_MAPPER]
-      ),
-    ])
-  );
-}