From 547f8dc44f418b18a9a523ce9042ba5fa81dd9c6 Mon Sep 17 00:00:00 2001 From: David Cho-Lerat Date: Thu, 1 Feb 2024 09:38:48 +0100 Subject: [PATCH] SONAR-21556 Metrcis can not be <= 0 or >= 100% --- .../src/main/js/apps/overview/utils.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/overview/utils.tsx b/server/sonar-web/src/main/js/apps/overview/utils.tsx index b6a894181f7..0745bc43797 100644 --- a/server/sonar-web/src/main/js/apps/overview/utils.tsx +++ b/server/sonar-web/src/main/js/apps/overview/utils.tsx @@ -26,7 +26,7 @@ import { formatMeasure } from '../../helpers/measures'; import { parseAsString } from '../../helpers/query'; import { SoftwareQuality } from '../../types/clean-code-taxonomy'; import { IssueType } from '../../types/issues'; -import { MetricKey } from '../../types/metrics'; +import { MetricKey, MetricType } from '../../types/metrics'; import { AnalysisMeasuresVariations, MeasureHistory } from '../../types/project-activity'; import { QualityGateStatusConditionEnhanced } from '../../types/quality-gates'; import { Dict, RawQuery } from '../../types/types'; @@ -257,17 +257,33 @@ export function getConditionRequiredLabel( intl: IntlShape, failed = false, ) { + let operator = condition.op === 'GT' ? '≤' : '≥'; + + if (operator === '≤' && condition.error === '0') { + operator = '='; + } + + if ( + operator === '≥' && + condition.error === '100' && + condition.measure.metric.type === MetricType.Percent + ) { + operator = '='; + } + const conditionEl = ( <> - {condition.op === 'GT' ? '≤' : '≥'}{' '} + {operator}{' '} {formatMeasure(condition.error, condition.measure.metric.type, { decimals: 2, omitExtraDecimalZeros: true, })} ); + return intl.formatMessage( { id: 'overview.quality_gate.required_x' }, + { requirement: failed ? {conditionEl} : conditionEl, }, -- 2.39.5