From: David Cho-Lerat Date: Thu, 1 Feb 2024 08:38:48 +0000 (+0100) Subject: SONAR-21556 Metrcis can not be <= 0 or >= 100% X-Git-Tag: 10.4.0.87286~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=547f8dc44f418b18a9a523ce9042ba5fa81dd9c6;p=sonarqube.git SONAR-21556 Metrcis can not be <= 0 or >= 100% --- 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, },