]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21556 Metrcis can not be <= 0 or >= 100%
authorDavid Cho-Lerat <david.cho-lerat@sonarsource.com>
Thu, 1 Feb 2024 08:38:48 +0000 (09:38 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 1 Feb 2024 20:02:47 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/overview/utils.tsx

index b6a894181f78137da6a8faae462645494c2f3701..0745bc437970af1c280af4b57fce008ed9ea40b4 100644 (file)
@@ -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 ? <b>{conditionEl}</b> : conditionEl,
     },