]> source.dussan.org Git - sonarqube.git/commitdiff
MMF-3988 Hide ratings and remove legacy mode setting
authorViktor Vorona <viktor.vorona@sonarsource.com>
Thu, 19 Sep 2024 12:48:00 +0000 (14:48 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 19 Sep 2024 20:03:00 +0000 (20:03 +0000)
24 files changed:
server/sonar-web/src/main/js/app/components/ChangeInCalculationPill.tsx
server/sonar-web/src/main/js/apps/code/components/CodeAppRenderer.tsx
server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx
server/sonar-web/src/main/js/apps/component-measures/components/ComponentMeasuresApp.tsx
server/sonar-web/src/main/js/apps/component-measures/utils.ts
server/sonar-web/src/main/js/apps/overview/branches/BranchOverviewRenderer.tsx
server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx
server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx
server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx
server/sonar-web/src/main/js/apps/projects/components/__tests__/PageSidebar-test.tsx
server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx
server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx
server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx
server/sonar-web/src/main/js/components/facets/SeverityFacet.tsx
server/sonar-web/src/main/js/components/shared/AnalysisMissingInfoMessage.tsx
server/sonar-web/src/main/js/queries/settings.ts
server/sonar-webserver/build.gradle
server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-webserver/src/main/java/org/sonar/server/platform/telemetry/TelemetryLegacyModePropertyProvider.java [deleted file]
server/sonar-webserver/src/test/java/org/sonar/server/platform/telemetry/TelemetryLegacyModePropertyProviderTest.java [deleted file]
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java
sonar-core/src/main/java/org/sonar/core/config/LegacyRatingConstants.java [deleted file]
sonar-core/src/main/java/org/sonar/core/config/LegacyRatingProperties.java [deleted file]
sonar-core/src/test/java/org/sonar/core/config/LegacyRatingPropertiesTest.java [deleted file]

index af82e478ded3e2f29331655c51cd85f6a55edd54..14bbb967625ae8f88315f7d1c9ae9dc15dd6b6e2 100644 (file)
@@ -23,7 +23,6 @@ import * as React from 'react';
 import DocumentationLink from '../../components/common/DocumentationLink';
 import { DocLink } from '../../helpers/doc-links';
 import { translate } from '../../helpers/l10n';
-import { useIsLegacyCCTMode } from '../../queries/settings';
 import { ComponentQualifier } from '../../sonar-aligned/types/component';
 
 interface Props {
@@ -32,11 +31,11 @@ interface Props {
 
 export default function ChangeInCalculation({ qualifier }: Readonly<Props>) {
   const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
-  const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
+  // const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
 
-  if (isLegacy || isLoading) {
-    return null;
-  }
+  // if (isLegacy || isLoading) {
+  //   return null;
+  // }
 
   return (
     <Popover
index 173311aee9adf910c714ee6ba401d6445b173c8a..9b622c225032962f02bf51bc61c612e46cc9e6f9 100644 (file)
@@ -124,7 +124,7 @@ export default function CodeAppRenderer(props: Readonly<Props>) {
   );
 
   const filteredMetrics = difference(metricKeys, [
-    ...(allComponentsHaveSoftwareQualityMeasures && !isLegacy
+    ...(allComponentsHaveSoftwareQualityMeasures
       ? OLD_TAXONOMY_METRICS
       : CCT_SOFTWARE_QUALITY_METRICS),
     ...(allComponentsHaveRatings && !isLegacy
index 01043b60288316ce1a6c45394c7cfb8834a7b4f4..c43001836f61ac488a53b553c6e93c434c9e96db 100644 (file)
@@ -92,20 +92,21 @@ describe('rendering', () => {
     await user.click(ui.maintainabilityDomainBtn.get());
     [
       'component_measures.metric.new_maintainability_issues.name 5',
-      'Software Quality Maintainability Remediation Effort on new code work_duration.x_minutes.1',
-      'Software Quality Technical Debt Ratio on New Code 1.0%',
-      'Software Quality Maintainability Rating on New Code metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%',
+      'Added Technical Debt work_duration.x_minutes.1',
+      'Technical Debt Ratio on New Code 1.0%',
+      'Maintainability Rating on New Code metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%',
       'component_measures.metric.maintainability_issues.name 2',
-      'Software Quality Maintainability Remediation Effort work_duration.x_minutes.1',
-      'Software Quality Technical Debt Ratio 1.0%',
-      'Software Quality Maintainability Rating metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%',
-      'Software Quality Effort to Reach Maintainability Rating A work_duration.x_minutes.1',
+      'Technical Debt work_duration.x_minutes.1',
+      'Technical Debt Ratio 1.0%',
+      'Maintainability Rating metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%',
+      'Effort to Reach Maintainability Rating A work_duration.x_minutes.1',
     ].forEach((measure) => {
       expect(ui.measureLink(measure).get()).toBeInTheDocument();
     });
   });
 
-  it('should correctly render the default overview and navigation in legacy mode', async () => {
+  // eslint-disable-next-line jest/no-disabled-tests
+  it.skip('should correctly render the default overview and navigation in legacy mode', async () => {
     settingsHandler.set(SettingsKey.LegacyMode, 'true');
     const { ui, user } = getPageObject();
     renderMeasuresApp();
@@ -208,10 +209,11 @@ describe('rendering', () => {
     ].forEach((measure) => {
       expect(ui.measureLink(measure).get()).toBeInTheDocument();
     });
-    expect(screen.getByText('overview.missing_project_dataTRK')).toBeInTheDocument();
+    // expect(screen.getByText('overview.missing_project_dataTRK')).toBeInTheDocument();
   });
 
-  it('should show old measures and no flag message if no rating measures and legacy mode', async () => {
+  // eslint-disable-next-line jest/no-disabled-tests
+  it.skip('should show old measures and no flag message if no rating measures and legacy mode', async () => {
     settingsHandler.set(SettingsKey.LegacyMode, 'true');
     measuresHandler.deleteComponentMeasure(
       'foo',
@@ -517,7 +519,7 @@ describe('navigation', () => {
     await user.click(
       ui
         .measureLink(
-          'Software Quality Maintainability Rating metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%',
+          'Maintainability Rating on New Code metric.has_rating_X.E metric.sqale_rating.tooltip.E.0.0%',
         )
         .get(),
     );
index bd7e35b6aa6d8b6e2239e46d699aadf380ab5165..f2b71316ca8a6fc7d6d06848d2d3107e6909e7dc 100644 (file)
@@ -44,10 +44,7 @@ import { enhanceMeasure } from '../../../components/measure/utils';
 import '../../../components/search-navigator.css';
 import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage';
 import { translate } from '../../../helpers/l10n';
-import {
-  areCCTMeasuresComputed,
-  areSoftwareQualityRatingsComputed,
-} from '../../../helpers/measures';
+import { areCCTMeasuresComputed } from '../../../helpers/measures';
 import { useCurrentBranchQuery } from '../../../queries/branch';
 import { useMeasuresComponentQuery } from '../../../queries/measures';
 
@@ -226,8 +223,7 @@ export default function ComponentMeasuresApp() {
                   />
                 </FlagMessage>
               )}
-              {(!areCCTMeasuresComputed(measures) ||
-                !areSoftwareQualityRatingsComputed(measures)) && (
+              {!areCCTMeasuresComputed(measures) && (
                 <AnalysisMissingInfoMessage
                   className="sw-mb-4"
                   qualifier={component?.qualifier as ComponentQualifier}
index e47f720209e2e2b767eb59174dfb11e98189b344..3e1e38a7849319d1b7ef16de200d7ba4f66603e3 100644 (file)
@@ -118,7 +118,7 @@ export const populateDomainsFromMeasures = memoize(
         };
       });
 
-    if (!isLegacy && areLeakCCTMeasuresComputed(measures)) {
+    if (areLeakCCTMeasuresComputed(measures)) {
       populatedMeasures = populatedMeasures.filter(
         (measure) => !LEAK_OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
       );
@@ -141,7 +141,7 @@ export const populateDomainsFromMeasures = memoize(
       );
     }
 
-    if (!isLegacy && areCCTMeasuresComputed(measures)) {
+    if (areCCTMeasuresComputed(measures)) {
       populatedMeasures = populatedMeasures.filter(
         (measure) => !OLD_TAXONOMY_METRICS.includes(measure.metric.key as MetricKey),
       );
index 419ea64ef89e9d4bad92620fdd539f21137d1c7f..82dd9f0f985d88761e565a7c3434e074f55bd0bf 100644 (file)
@@ -28,11 +28,7 @@ import { CurrentUserContext } from '../../../app/components/current-user/Current
 import AnalysisMissingInfoMessage from '../../../components/shared/AnalysisMissingInfoMessage';
 import { parseDate } from '../../../helpers/dates';
 import { translate } from '../../../helpers/l10n';
-import {
-  areCCTMeasuresComputed,
-  areSoftwareQualityRatingsComputed,
-  isDiffMetric,
-} from '../../../helpers/measures';
+import { areCCTMeasuresComputed, isDiffMetric } from '../../../helpers/measures';
 import { CodeScope } from '../../../helpers/urls';
 import { useDismissNoticeMutation } from '../../../queries/users';
 import { ApplicationPeriod } from '../../../types/application';
@@ -119,8 +115,9 @@ export default function BranchOverviewRenderer(props: BranchOverviewRendererProp
   const hasNewCodeMeasures = measures.some((m) => isDiffMetric(m.metric.key));
 
   // Check if any potentially missing uncomputed measure is not present
-  const isMissingMeasures =
-    !areCCTMeasuresComputed(measures) || !areSoftwareQualityRatingsComputed(measures);
+  // const isMissingMeasures =
+  //   !areCCTMeasuresComputed(measures) || !areSoftwareQualityRatingsComputed(measures);
+  const isMissingMeasures = !areCCTMeasuresComputed(measures);
 
   const selectTab = (tab: CodeScope) => {
     router.replace({ query: { ...query, codeScope: tab } });
index 96cd155eecab5eaca5432a521816c1b9573ec26e..ab93b482172774b6c1609a61eb327b52eeb3d84a 100644 (file)
@@ -31,7 +31,6 @@ import {
   getIssueTypeBySoftwareQuality,
 } from '../../../helpers/issues';
 import { isDefined } from '../../../helpers/types';
-import { useIsLegacyCCTMode } from '../../../queries/settings';
 import { Branch } from '../../../types/branch-like';
 import { SoftwareImpactMeasureData, SoftwareQuality } from '../../../types/clean-code-taxonomy';
 import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates';
@@ -52,14 +51,12 @@ export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdow
   const { component, conditions, softwareQuality, ratingMetricKey, measures, branch } = props;
 
   const intl = useIntl();
-  const { data: isLegacy } = useIsLegacyCCTMode();
+  // const { data: isLegacy } = useIsLegacyCCTMode();
 
   // Find measure for this software quality
   const metricKey = softwareQualityToMeasure(softwareQuality);
   const measureRaw = measures.find((m) => m.metric.key === metricKey);
-  const measure = isLegacy
-    ? undefined
-    : (JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData);
+  const measure = JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData;
   const alternativeMeasure = measures.find(
     (m) => m.metric.key === SOFTWARE_QUALITIES_METRIC_KEYS_MAP[softwareQuality].deprecatedMetric,
   );
index 0bc93912b3750d03a2d5199091c30dfecb1703b7..76677c61c2e12a8d834cb0b53517b737067f7cd7 100644 (file)
@@ -313,11 +313,11 @@ describe('project overview', () => {
       'overview.measures.software_impact.improve_rating_tooltip.A.software_quality.RELIABILITY.software_quality.reliability.A.overview.measures.software_impact.severity.LOW.improve_tooltip',
     );
 
-    ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'D', 2);
+    ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'E', 2);
     await ui.expectSoftwareImpactMeasureCardRatingTooltip(
       SoftwareQuality.Maintainability,
-      'D',
-      'overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY.software_quality.MAINTAINABILITY.software_quality.maintainability.D.overview.measures.software_impact.severity.HIGH.improve_tooltip',
+      'E',
+      'overview.measures.software_impact.improve_rating_tooltip.MAINTAINABILITY.software_quality.MAINTAINABILITY.software_quality.maintainability.E.overview.measures.software_impact.severity.HIGH.improve_tooltip',
     );
   });
 
@@ -328,7 +328,7 @@ describe('project overview', () => {
 
     await user.click(await ui.overallCodeButton.find());
 
-    ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'D', 2, '');
+    ui.expectSoftwareImpactMeasureCard(SoftwareQuality.Maintainability, 'E', 2, '');
   });
 
   it('should render old measures if software impact are missing', async () => {
@@ -435,7 +435,8 @@ describe('project overview', () => {
     },
   );
 
-  it('should display info about missing analysis if a project did not compute ratings', async () => {
+  // eslint-disable-next-line jest/no-disabled-tests
+  it.skip('should display info about missing analysis if a project did not compute ratings', async () => {
     measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_security_rating);
     measuresHandler.deleteComponentMeasure(
       'foo',
@@ -468,7 +469,8 @@ describe('project overview', () => {
     ).toBeInTheDocument();
   });
 
-  it('should display old measures if in legacy mode', async () => {
+  // eslint-disable-next-line jest/no-disabled-tests
+  it.skip('should display old measures if in legacy mode', async () => {
     settingsHandler.set(SettingsKey.LegacyMode, 'true');
     const { user, ui } = getPageObjects();
     renderBranchOverview();
index e8132d76bef57f6fee2f75136b343b5bb9246d3b..84b3223f85b8a88b50060e451ac5604d15cfc6c0 100644 (file)
@@ -553,7 +553,8 @@ describe('graph interactions', () => {
 });
 
 describe('ratings', () => {
-  it('should combine old and new rating + gaps', async () => {
+  // eslint-disable-next-line jest/no-disabled-tests
+  it.skip('should combine old and new rating + gaps', async () => {
     timeMachineHandler.setMeasureHistory([
       mockMeasureHistory({
         metric: MetricKey.reliability_rating,
@@ -611,7 +612,8 @@ describe('ratings', () => {
     expect(ui.gapInfoMessage.get()).toBeInTheDocument();
   });
 
-  it('should not show old rating if new one was always there', async () => {
+  // eslint-disable-next-line jest/no-disabled-tests
+  it.skip('should not show old rating if new one was always there', async () => {
     timeMachineHandler.setMeasureHistory([
       mockMeasureHistory({
         metric: MetricKey.reliability_rating,
index 927df18e7aa99d2c204fd697f38897916abc6317..0e65b8204444ee0d3ad0c37c4933486b85e417f9 100644 (file)
@@ -95,7 +95,8 @@ it('should show legacy filters', async () => {
   ).toBeInTheDocument();
 });
 
-it('should show non legacy filters', async () => {
+// eslint-disable-next-line jest/no-disabled-tests
+it.skip('should show non legacy filters', async () => {
   settingsHandler.set(SettingsKey.LegacyMode, 'false');
   renderPageSidebar();
 
index ec6a4e19ddbb1eff6be79e1c5b277101f4e9763c..59890b720d8d0d318712fe04d8a4e27b2efd09d7 100644 (file)
@@ -73,13 +73,13 @@ function renderFirstLine(
     MetricKey.maintainability_issues,
     MetricKey.security_issues,
   ].every((key) => measures[key] === undefined);
-  const noRatingMetrics = [
-    MetricKey.software_quality_reliability_rating,
-    MetricKey.software_quality_maintainability_rating,
-    MetricKey.software_quality_security_rating,
-  ].every((key) => measures[key] === undefined);
+  // const noRatingMetrics = [
+  //   MetricKey.software_quality_reliability_rating,
+  //   MetricKey.software_quality_maintainability_rating,
+  //   MetricKey.software_quality_security_rating,
+  // ].every((key) => measures[key] === undefined);
   const awaitingScan =
-    (noSoftwareQualityMetrics || noRatingMetrics) &&
+    noSoftwareQualityMetrics &&
     !isNewCode &&
     !isEmpty(analysisDate) &&
     measures.ncloc !== undefined;
index 0f0b31ef7996c4dfe72b5beb441fd4159d59db00..457f82dc06ed6e2820d6fa6acc8b49a2499e810b 100644 (file)
@@ -31,7 +31,6 @@ import RatingComponent from '../../../../app/components/metrics/RatingComponent'
 import { duplicationRatingConverter } from '../../../../components/measure/utils';
 import { translate } from '../../../../helpers/l10n';
 import { isDefined } from '../../../../helpers/types';
-import { useIsLegacyCCTMode } from '../../../../queries/settings';
 import { Dict } from '../../../../types/types';
 import ProjectCardMeasure from './ProjectCardMeasure';
 
@@ -116,7 +115,7 @@ function renderDuplication(props: ProjectCardMeasuresProps) {
   );
 }
 
-function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) {
+function renderRatings(props: ProjectCardMeasuresProps) {
   const { isNewCode, measures, componentKey } = props;
 
   const measuresByCodeLeak = isNewCode
@@ -126,7 +125,7 @@ function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) {
           iconLabel: translate(`metric.${MetricKey.security_issues}.short_name`),
           noShrink: true,
           metricKey:
-            isLegacy || measures[MetricKey.security_issues] === undefined
+            measures[MetricKey.security_issues] === undefined
               ? MetricKey.vulnerabilities
               : MetricKey.security_issues,
           metricRatingKey: MetricKey.security_rating,
@@ -135,7 +134,7 @@ function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) {
         {
           iconLabel: translate(`metric.${MetricKey.reliability_issues}.short_name`),
           metricKey:
-            isLegacy || measures[MetricKey.reliability_issues] === undefined
+            measures[MetricKey.reliability_issues] === undefined
               ? MetricKey.bugs
               : MetricKey.reliability_issues,
           metricRatingKey: MetricKey.reliability_rating,
@@ -144,7 +143,7 @@ function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) {
         {
           iconLabel: translate(`metric.${MetricKey.maintainability_issues}.short_name`),
           metricKey:
-            isLegacy || measures[MetricKey.maintainability_issues] === undefined
+            measures[MetricKey.maintainability_issues] === undefined
               ? MetricKey.code_smells
               : MetricKey.maintainability_issues,
           metricRatingKey: MetricKey.sqale_rating,
@@ -196,7 +195,7 @@ function renderRatings(props: ProjectCardMeasuresProps, isLegacy: boolean) {
 
 export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) {
   const { isNewCode, measures, componentQualifier } = props;
-  const { data: isLegacy } = useIsLegacyCCTMode();
+  // const { data: isLegacy } = useIsLegacyCCTMode();
 
   const { ncloc } = measures;
 
@@ -212,7 +211,7 @@ export default function ProjectCardMeasures(props: ProjectCardMeasuresProps) {
 
   const measureList = [
     renderNewIssues(props),
-    ...renderRatings(props, !!isLegacy),
+    ...renderRatings(props),
     renderCoverage(props),
     renderDuplication(props),
   ].filter(isDefined);
index 998ac41cc8c8c96d851e7e53693da023f6d403a8..56d5e491bb5661eb7a9c91f0c9f2203d8ffd6b41 100644 (file)
@@ -145,6 +145,7 @@ describe('upgrade scenario (awaiting scan)', () => {
       value: '3',
     }),
   };
+
   beforeEach(() => {
     measuresHandler.setComponents({
       component: mockComponent({ key: PROJECT.key }),
@@ -155,9 +156,13 @@ describe('upgrade scenario (awaiting scan)', () => {
       [PROJECT.key]: oldRatings,
     });
   });
+
   it('should not display awaiting analysis badge and do not display old measures', async () => {
     measuresHandler.registerComponentMeasures({
-      [PROJECT.key]: newRatings,
+      [PROJECT.key]: {
+        ...newRatings,
+        ...oldRatings,
+      },
     });
     renderProjectCard({
       ...PROJECT,
@@ -182,13 +187,13 @@ describe('upgrade scenario (awaiting scan)', () => {
     expect(screen.getByText('1')).toBeInTheDocument();
     expect(screen.getByText('2')).toBeInTheDocument();
     expect(screen.getByText('3')).toBeInTheDocument();
-    await waitFor(() => expect(screen.getAllByText('B')).toHaveLength(3));
+    await waitFor(() => expect(screen.getAllByText('A')).toHaveLength(3));
     await waitFor(() => expect(screen.getAllByText('C')).toHaveLength(1));
     expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument();
     expect(screen.queryByText('4')).not.toBeInTheDocument();
     expect(screen.queryByText('5')).not.toBeInTheDocument();
     expect(screen.queryByText('6')).not.toBeInTheDocument();
-    expect(screen.queryByText('A')).not.toBeInTheDocument();
+    expect(screen.queryByText('B')).not.toBeInTheDocument();
   });
 
   it('should display awaiting analysis badge and show the old measures', async () => {
@@ -230,8 +235,9 @@ describe('upgrade scenario (awaiting scan)', () => {
         [MetricKey.vulnerabilities]: '6',
       },
     });
-    expect(await screen.findByText('projects.awaiting_scan')).toBeInTheDocument();
-    expect(screen.getByText('1')).toBeInTheDocument();
+    expect(await screen.findByText('1')).toBeInTheDocument();
+    expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument();
+
     expect(screen.getByText('2')).toBeInTheDocument();
     expect(screen.getByText('3')).toBeInTheDocument();
     expect(screen.queryByText('4')).not.toBeInTheDocument();
@@ -284,7 +290,8 @@ describe('upgrade scenario (awaiting scan)', () => {
     expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument();
   });
 
-  it('should not display awaiting analysis badge if legacy mode is enabled', async () => {
+  // eslint-disable-next-line jest/no-disabled-tests
+  it.skip('should not display awaiting analysis badge if legacy mode is enabled', async () => {
     settingsHandler.set(SettingsKey.LegacyMode, 'true');
     renderProjectCard({
       ...PROJECT,
@@ -303,7 +310,8 @@ describe('upgrade scenario (awaiting scan)', () => {
     expect(screen.queryByText('projects.awaiting_scan')).not.toBeInTheDocument();
   });
 
-  it('should not display new values if legacy mode is enabled', async () => {
+  // eslint-disable-next-line jest/no-disabled-tests
+  it.skip('should not display new values if legacy mode is enabled', async () => {
     settingsHandler.set(SettingsKey.LegacyMode, 'true');
     measuresHandler.registerComponentMeasures({
       [PROJECT.key]: {
index 3f7cae9eca6c7b77ee4a74ffa750b87453243ca1..c162b1eb62a8ddede3000c2019d573bebfd445e0 100644 (file)
@@ -25,6 +25,7 @@ import { useIntl } from 'react-intl';
 import { IMPACT_SEVERITIES } from '../../helpers/constants';
 import { DocLink } from '../../helpers/doc-links';
 import { translate } from '../../helpers/l10n';
+import { SoftwareImpactSeverity } from '../../types/clean-code-taxonomy';
 import DocumentationLink from '../common/DocumentationLink';
 import SoftwareImpactSeverityIcon from '../icon-mappers/SoftwareImpactSeverityIcon';
 import Facet, { BasicProps } from './Facet';
@@ -46,10 +47,45 @@ export default function SeverityFacet(props: Readonly<BasicProps>) {
     [],
   );
 
+  const isNotBlockerOrInfo = (severity: string) =>
+    severity !== SoftwareImpactSeverity.Blocker && severity !== SoftwareImpactSeverity.Info;
+
   return (
     <Facet
       {...props}
-      options={IMPACT_SEVERITIES}
+      stats={Object.fromEntries(
+        Object.entries(props.stats ?? {})
+          .filter(([key]) => isNotBlockerOrInfo(key))
+          .map(([key, value]) => {
+            switch (key) {
+              case SoftwareImpactSeverity.Low:
+                return [key, value + (props.stats?.[SoftwareImpactSeverity.Info] ?? 0)];
+              case SoftwareImpactSeverity.High:
+                return [key, value + (props.stats?.[SoftwareImpactSeverity.Blocker] ?? 0)];
+              default:
+                return [key, value];
+            }
+          }),
+      )}
+      onChange={(values) => {
+        props.onChange({
+          ...values,
+          impactSeverities: (values.impactSeverities as string[] | undefined)
+            ?.map((s) => {
+              switch (s) {
+                case SoftwareImpactSeverity.Low:
+                  return [SoftwareImpactSeverity.Info, SoftwareImpactSeverity.Low];
+                case SoftwareImpactSeverity.High:
+                  return [SoftwareImpactSeverity.Blocker, SoftwareImpactSeverity.High];
+                default:
+                  return s;
+              }
+            })
+            .flat(),
+        });
+      }}
+      values={props.values.filter(isNotBlockerOrInfo)}
+      options={IMPACT_SEVERITIES.filter(isNotBlockerOrInfo)}
       property="impactSeverities"
       renderName={renderName}
       renderTextName={renderTextName}
index b0bb17d6cbf9af281f23af219b514376bf31c3b3..a3a39f3620c9d56411721d2be331c1b55751a88e 100644 (file)
@@ -22,7 +22,6 @@ import { FlagMessage } from 'design-system';
 import * as React from 'react';
 import { FormattedMessage, useIntl } from 'react-intl';
 import { DocLink } from '../../helpers/doc-links';
-import { useIsLegacyCCTMode } from '../../queries/settings';
 import DocumentationLink from '../common/DocumentationLink';
 
 interface AnalysisMissingInfoMessageProps {
@@ -36,10 +35,10 @@ export default function AnalysisMissingInfoMessage({
   qualifier,
   className,
 }: Readonly<AnalysisMissingInfoMessageProps>) {
-  const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
   const intl = useIntl();
+  // const { data: isLegacy, isLoading } = useIsLegacyCCTMode();
 
-  if (hide || isLoading || isLegacy) {
+  if (hide) {
     return null;
   }
 
index 5deba9ca1988d344bb640e3e57f25c3bd75eb72f..5d1cb2f2d6cfad96851327b7c97b4a6f2d2b789a 100644 (file)
@@ -21,7 +21,7 @@ import { queryOptions, useMutation, useQuery, useQueryClient } from '@tanstack/r
 import { addGlobalSuccessMessage } from 'design-system';
 import { getValue, getValues, resetSettingValue, setSettingValue } from '../api/settings';
 import { translate } from '../helpers/l10n';
-import { ExtendedSettingDefinition, SettingsKey } from '../types/settings';
+import { ExtendedSettingDefinition } from '../types/settings';
 import { createQueryHook } from './common';
 import { invalidateAllMeasures } from './measures';
 
@@ -48,10 +48,14 @@ export const useGetValueQuery = createQueryHook(
 );
 
 export const useIsLegacyCCTMode = () => {
-  return useGetValueQuery(
-    { key: SettingsKey.LegacyMode },
-    { staleTime: Infinity, select: (data) => data?.value === 'true' },
-  );
+  return useQuery({
+    queryKey: ['mocked-legacy-mode'],
+    queryFn: () => Promise.resolve(true),
+  });
+  // return useGetValueQuery(
+  //   { key: SettingsKey.LegacyMode },
+  //   { staleTime: Infinity, select: (data) => data?.value === 'true' },
+  // );
 };
 
 export function useResetSettingsMutation() {
index 9a0e75999715d252708cc5d63ef21c0133c616d8..6b055e5d06accac9dd3f21234325250093797e5a 100644 (file)
@@ -33,7 +33,6 @@ dependencies {
   testImplementation 'com.github.spotbugs:spotbugs-annotations'
   testImplementation 'com.tngtech.java:junit-dataprovider'
   testImplementation 'org.junit.jupiter:junit-jupiter-api'
-  testImplementation 'org.junit.jupiter:junit-jupiter-params'
   testImplementation 'org.mockito:mockito-core'
   testImplementation 'org.eclipse.jetty:jetty-server'
   testImplementation 'org.eclipse.jetty:jetty-servlet'
index ea7c7271e4bb9899690be1a0888afbe1205ef146..a839d435b17134e9a67a245ff181f50828fcaa6d 100644 (file)
@@ -189,7 +189,6 @@ import org.sonar.server.platform.WebCoreExtensionsInstaller;
 import org.sonar.server.platform.db.CheckAnyonePermissionsAtStartup;
 import org.sonar.server.platform.telemetry.ProjectCppAutoconfigTelemetryProvider;
 import org.sonar.server.platform.telemetry.TelemetryFipsEnabledProvider;
-import org.sonar.server.platform.telemetry.TelemetryLegacyModePropertyProvider;
 import org.sonar.server.platform.telemetry.TelemetryNclocProvider;
 import org.sonar.server.platform.telemetry.TelemetryUserEnabledProvider;
 import org.sonar.server.platform.telemetry.TelemetryVersionProvider;
@@ -670,7 +669,6 @@ public class PlatformLevel4 extends PlatformLevel {
       // new telemetry metrics
       ProjectCppAutoconfigTelemetryProvider.class,
       TelemetryVersionProvider.class,
-      TelemetryLegacyModePropertyProvider.class,
       TelemetryNclocProvider.class,
       TelemetryUserEnabledProvider.class,
       TelemetryFipsEnabledProvider.class,
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/telemetry/TelemetryLegacyModePropertyProvider.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/telemetry/TelemetryLegacyModePropertyProvider.java
deleted file mode 100644 (file)
index 97c8bb8..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.platform.telemetry;
-
-import java.util.Optional;
-import org.sonar.db.DbClient;
-import org.sonar.db.property.PropertyDto;
-import org.sonar.telemetry.core.Dimension;
-import org.sonar.telemetry.core.Granularity;
-import org.sonar.telemetry.core.TelemetryDataProvider;
-import org.sonar.telemetry.core.TelemetryDataType;
-
-import static org.sonar.core.config.LegacyRatingConstants.LEGACY_RATING_MODE_ENABLED;
-import static org.sonar.telemetry.core.Dimension.INSTALLATION;
-import static org.sonar.telemetry.core.Granularity.WEEKLY;
-import static org.sonar.telemetry.core.TelemetryDataType.BOOLEAN;
-
-public class TelemetryLegacyModePropertyProvider implements TelemetryDataProvider<Boolean> {
-  private final DbClient dbClient;
-
-  public TelemetryLegacyModePropertyProvider(DbClient dbClient) {
-    this.dbClient = dbClient;
-  }
-
-  @Override
-  public String getMetricKey() {
-    return "legacy_rating_mode_enabled";
-  }
-
-  @Override
-  public Dimension getDimension() {
-    return INSTALLATION;
-  }
-
-  @Override
-  public Granularity getGranularity() {
-    return WEEKLY;
-  }
-
-  @Override
-  public TelemetryDataType getType() {
-    return BOOLEAN;
-  }
-
-  @Override
-  public Optional<Boolean> getValue() {
-    PropertyDto property = dbClient.propertiesDao().selectGlobalProperty(LEGACY_RATING_MODE_ENABLED);
-    return property == null ? Optional.of(false) : Optional.of(Boolean.valueOf(property.getValue()));
-  }
-}
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/telemetry/TelemetryLegacyModePropertyProviderTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/telemetry/TelemetryLegacyModePropertyProviderTest.java
deleted file mode 100644 (file)
index 7a1aada..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.platform.telemetry;
-
-import java.util.Optional;
-import java.util.stream.Stream;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.sonar.db.DbClient;
-import org.sonar.db.property.PropertiesDao;
-import org.sonar.db.property.PropertyDto;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.sonar.core.config.LegacyRatingConstants.LEGACY_RATING_MODE_ENABLED;
-import static org.sonar.telemetry.core.Dimension.INSTALLATION;
-import static org.sonar.telemetry.core.Granularity.WEEKLY;
-import static org.sonar.telemetry.core.TelemetryDataType.BOOLEAN;
-
-class TelemetryLegacyModePropertyProviderTest {
-  private final DbClient dbClient = mock();
-  private final PropertiesDao propertiesDao = mock();
-  private final TelemetryLegacyModePropertyProvider underTest = new TelemetryLegacyModePropertyProvider(dbClient);
-
-  @ParameterizedTest
-  @MethodSource("getValues")
-  void getter_should_return_correct_values(Boolean value, Boolean expected) {
-    when(dbClient.propertiesDao()).thenReturn(propertiesDao);
-    if (value == null) {
-      when(dbClient.propertiesDao().selectGlobalProperty(LEGACY_RATING_MODE_ENABLED))
-        .thenReturn(null);
-    } else {
-      when(dbClient.propertiesDao().selectGlobalProperty(LEGACY_RATING_MODE_ENABLED))
-        .thenReturn(new PropertyDto().setValue(value.toString()));
-    }
-
-    assertEquals("legacy_rating_mode_enabled", underTest.getMetricKey());
-    assertEquals(INSTALLATION, underTest.getDimension());
-    assertEquals(WEEKLY, underTest.getGranularity());
-    assertEquals(BOOLEAN, underTest.getType());
-    assertEquals(Optional.of(expected), underTest.getValue());
-  }
-
-  public static Stream<Arguments> getValues() {
-    return Stream.of(
-      Arguments.of(true, true),
-      Arguments.of(false, false),
-      Arguments.of(null, false)
-    );
-  }
-
-}
index 86f2f2ea797d888f1c1c0d6c9864108e6249ee64..758efac19cd3b21a66eed4bbb197bdb267446487 100644 (file)
@@ -68,7 +68,6 @@ public class CorePropertyDefinitions {
     defs.addAll(PurgeProperties.all());
     defs.addAll(EmailSettings.definitions());
     defs.addAll(ScannerProperties.all());
-    defs.addAll(LegacyRatingProperties.all());
 
     defs.addAll(asList(
       PropertyDefinition.builder(CoreProperties.MODULE_LEVEL_ARCHIVED_SETTINGS)
diff --git a/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingConstants.java b/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingConstants.java
deleted file mode 100644 (file)
index 847de4c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.config;
-
-public class LegacyRatingConstants {
-
-  public static final String LEGACY_RATING_CATEGORY = "Legacy rating mode";
-  public static final String LEGACY_RATING_SUB_CATEGORY = "Legacy rating mode";
-  public static final String LEGACY_RATING_MODE_ENABLED = "sonar.legacy.ratings.mode.enabled";
-
-  private LegacyRatingConstants() {
-    //class cannot be instantiated
-  }
-}
diff --git a/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingProperties.java b/sonar-core/src/main/java/org/sonar/core/config/LegacyRatingProperties.java
deleted file mode 100644 (file)
index ed621ff..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.config;
-
-import java.util.Collections;
-import java.util.List;
-import org.sonar.api.PropertyType;
-import org.sonar.api.config.PropertyDefinition;
-
-import static org.sonar.core.config.LegacyRatingConstants.LEGACY_RATING_CATEGORY;
-import static org.sonar.core.config.LegacyRatingConstants.LEGACY_RATING_MODE_ENABLED;
-import static org.sonar.core.config.LegacyRatingConstants.LEGACY_RATING_SUB_CATEGORY;
-
-public final class LegacyRatingProperties {
-
-  private LegacyRatingProperties() {
-  }
-
-  public static List<PropertyDefinition> all() {
-    return Collections.singletonList(
-      PropertyDefinition.builder(LEGACY_RATING_MODE_ENABLED)
-        .defaultValue(Boolean.FALSE.toString())
-        .name("Enable legacy mode")
-        .description("Ratings have updated logic and have grades ranging from A to D, while the old scale ranges from A to E." +
-          "<br><br>" +
-          "If you choose legacy mode, ratings and other counts will be calculated using the former logic. The old ratings scale (A-E) is " +
-          "deprecated and is scheduled for replacement by the new scale (A-D) in the next LTA.")
-        .type(PropertyType.BOOLEAN)
-        .category(LEGACY_RATING_CATEGORY)
-        .subCategory(LEGACY_RATING_SUB_CATEGORY)
-        .index(1)
-        .build()
-    );
-
-  }
-}
diff --git a/sonar-core/src/test/java/org/sonar/core/config/LegacyRatingPropertiesTest.java b/sonar-core/src/test/java/org/sonar/core/config/LegacyRatingPropertiesTest.java
deleted file mode 100644 (file)
index 4c23430..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2024 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.core.config;
-
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class LegacyRatingPropertiesTest {
-  @Test
-  void all_shouldGetProperties() {
-    assertThat(LegacyRatingProperties.all()).hasSize(1);
-  }
-}