From c28b1f00f5a22ae0c13d7206eb54e8b7f396f44d Mon Sep 17 00:00:00 2001 From: Viktor Vorona Date: Thu, 4 Apr 2024 16:47:35 +0200 Subject: [PATCH] SONAR-21910 Remove custom mapping for measure domains --- .../main/js/apps/component-measures/utils.ts | 21 ++++--------------- .../src/main/js/helpers/mocks/metrics.ts | 9 +++++--- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/component-measures/utils.ts b/server/sonar-web/src/main/js/apps/component-measures/utils.ts index fb947000929..558ad1bf8fa 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/utils.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/utils.ts @@ -30,11 +30,11 @@ import { import { getLocalizedMetricName, translate } from '../../helpers/l10n'; import { MEASURES_REDIRECTION, - areLeakCCTMeasuresComputed, areCCTMeasuresComputed, + areLeakCCTMeasuresComputed, + getCCTMeasureValue, getDisplayMetrics, isDiffMetric, - getCCTMeasureValue, } from '../../helpers/measures'; import { cleanQuery, @@ -74,15 +74,6 @@ export const KNOWN_DOMAINS = [ 'Complexity', ]; -const CCT_METRIC_DOMAIN_MAP: Dict = { - [MetricKey.security_issues]: 'Security', - [MetricKey.new_security_issues]: 'Security', - [MetricKey.reliability_issues]: 'Reliability', - [MetricKey.new_reliability_issues]: 'Reliability', - [MetricKey.maintainability_issues]: 'Maintainability', - [MetricKey.new_maintainability_issues]: 'Maintainability', -}; - const DEPRECATED_METRICS = [ MetricKey.blocker_violations, MetricKey.new_blocker_violations, @@ -118,14 +109,10 @@ export const populateDomainsFromMeasures = memoize((measures: MeasureEnhanced[]) return { ...measure, - metric: { - ...measure.metric, - domain: CCT_METRIC_DOMAIN_MAP[measure.metric.key] ?? measure.metric.domain, - }, - ...(!isDiff && { value: calculatedValue }), - ...(isDiff && { leak: calculatedValue }), + ...{ [isDiff ? 'leak' : 'value']: calculatedValue }, }; }); + if (areLeakCCTMeasuresComputed(measures)) { populatedMeasures = populatedMeasures.filter( (measure) => !LEAK_OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey), diff --git a/server/sonar-web/src/main/js/helpers/mocks/metrics.ts b/server/sonar-web/src/main/js/helpers/mocks/metrics.ts index a909cef1232..60febc0fb71 100644 --- a/server/sonar-web/src/main/js/helpers/mocks/metrics.ts +++ b/server/sonar-web/src/main/js/helpers/mocks/metrics.ts @@ -915,6 +915,7 @@ export const DEFAULT_METRICS: Dict = { type: 'DATA', name: 'Reliability', description: 'Reliability issues', + domain: 'Reliability', direction: 0, qualitative: false, hidden: false, @@ -924,6 +925,7 @@ export const DEFAULT_METRICS: Dict = { type: 'DATA', name: 'New Reliability', description: 'New Reliability issues', + domain: 'Reliability', direction: 0, qualitative: false, hidden: false, @@ -1035,6 +1037,7 @@ export const DEFAULT_METRICS: Dict = { type: 'DATA', name: 'Security', description: 'Security issues', + domain: 'Security', direction: 0, qualitative: false, hidden: false, @@ -1044,7 +1047,7 @@ export const DEFAULT_METRICS: Dict = { type: 'DATA', name: 'Security', description: 'New Security issues', - domain: 'Issues', + domain: 'Security', direction: 0, qualitative: false, hidden: false, @@ -1214,7 +1217,7 @@ export const DEFAULT_METRICS: Dict = { type: 'DATA', name: 'Maintainability', description: 'Maintainability issues', - domain: 'Issues', + domain: 'Maintainability', direction: 0, qualitative: false, hidden: false, @@ -1224,7 +1227,7 @@ export const DEFAULT_METRICS: Dict = { type: 'DATA', name: 'Maintainability', description: 'New Maintainability issues', - domain: 'Issues', + domain: 'Maintainability', direction: 0, qualitative: false, hidden: false, -- 2.39.5