diff options
author | Ismail Cherri <ismail.cherri@sonarsource.com> | 2024-10-31 16:38:10 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-11-05 20:03:03 +0000 |
commit | 372a30452491480923650b70680d154caadbdbd0 (patch) | |
tree | 35381f14f0e6767c5164a87cf4fcdeba115a29a8 | |
parent | 3ffbe482c4ab61bbf9c4eae3b656244961152e3d (diff) | |
download | sonarqube-372a30452491480923650b70680d154caadbdbd0.tar.gz sonarqube-372a30452491480923650b70680d154caadbdbd0.zip |
SONAR-23298 Deprecate quality_issues in favor of software_quality_issues
30 files changed, 263 insertions, 288 deletions
diff --git a/server/sonar-web/src/main/js/api/mocks/data/measures.ts b/server/sonar-web/src/main/js/api/mocks/data/measures.ts index 593f2eb22f5..aafef6c4635 100644 --- a/server/sonar-web/src/main/js/api/mocks/data/measures.ts +++ b/server/sonar-web/src/main/js/api/mocks/data/measures.ts @@ -22,7 +22,6 @@ import { keyBy } from 'lodash'; import { MetricKey, MetricType } from '~sonar-aligned/types/metrics'; import { isDiffMetric } from '../../../helpers/measures'; import { mockMeasure } from '../../../helpers/testMocks'; -import { SoftwareImpactSeverity } from '../../../types/clean-code-taxonomy'; import { IssueDeprecatedStatus, IssueType, RawIssue } from '../../../types/issues'; import { Measure } from '../../../types/types'; import { ComponentTree } from './components'; @@ -59,80 +58,50 @@ function mockComponentMeasure(tree: ComponentTree, issueList: IssueData[], metri value: 'java=10000;javascript=5000;css=1000', }); - case MetricKey.security_issues: + case MetricKey.software_quality_security_issues: return mockMeasure({ metric: metricKey, - value: JSON.stringify({ - total: 1, - [SoftwareImpactSeverity.High]: 0, - [SoftwareImpactSeverity.Medium]: 1, - [SoftwareImpactSeverity.Low]: 0, - }), + value: '1', }); - case MetricKey.new_security_issues: + case MetricKey.new_software_quality_security_issues: return mockMeasure({ metric: metricKey, period: { index: 1, - value: JSON.stringify({ - total: 3, - [SoftwareImpactSeverity.High]: 2, - [SoftwareImpactSeverity.Medium]: 0, - [SoftwareImpactSeverity.Low]: 1, - }), + value: '3', }, value: undefined, }); - case MetricKey.reliability_issues: + case MetricKey.software_quality_reliability_issues: return mockMeasure({ metric: metricKey, - value: JSON.stringify({ - total: 3, - [SoftwareImpactSeverity.High]: 0, - [SoftwareImpactSeverity.Medium]: 2, - [SoftwareImpactSeverity.Low]: 1, - }), + value: '3', }); - case MetricKey.new_reliability_issues: + case MetricKey.new_software_quality_reliability_issues: return mockMeasure({ metric: metricKey, period: { index: 1, - value: JSON.stringify({ - total: 2, - [SoftwareImpactSeverity.High]: 0, - [SoftwareImpactSeverity.Medium]: 1, - [SoftwareImpactSeverity.Low]: 1, - }), + value: '2', }, value: undefined, }); - case MetricKey.maintainability_issues: + case MetricKey.software_quality_maintainability_issues: return mockMeasure({ metric: metricKey, - value: JSON.stringify({ - total: 2, - [SoftwareImpactSeverity.High]: 0, - [SoftwareImpactSeverity.Medium]: 0, - [SoftwareImpactSeverity.Low]: 1, - }), + value: '2', }); - case MetricKey.new_maintainability_issues: + case MetricKey.new_software_quality_maintainability_issues: return mockMeasure({ metric: metricKey, period: { index: 1, - value: JSON.stringify({ - total: 5, - [SoftwareImpactSeverity.High]: 2, - [SoftwareImpactSeverity.Medium]: 2, - [SoftwareImpactSeverity.Low]: 1, - }), + value: '5', }, value: undefined, }); @@ -364,17 +333,6 @@ export function getMetricTypeFromKey(metricKey: string) { return MetricType.Percent; } else if (metricKey.includes('_rating')) { return MetricType.Rating; - } else if ( - [ - MetricKey.reliability_issues, - MetricKey.new_reliability_issues, - MetricKey.security_issues, - MetricKey.new_security_issues, - MetricKey.maintainability_issues, - MetricKey.new_maintainability_issues, - ].includes(metricKey as MetricKey) - ) { - return MetricType.Data; } return MetricType.Integer; } diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts index 4b319d33240..c620624df31 100644 --- a/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts +++ b/server/sonar-web/src/main/js/apps/code/__tests__/Code-it.ts @@ -296,9 +296,9 @@ it('should correctly show measures for a project', async () => { const folderRow = ui.measureRow(/folderA/); [ [MetricKey.ncloc, '2'], - [MetricKey.security_issues, '4'], - [MetricKey.reliability_issues, '4'], - [MetricKey.maintainability_issues, '4'], + [MetricKey.software_quality_security_issues, '4'], + [MetricKey.software_quality_reliability_issues, '4'], + [MetricKey.software_quality_maintainability_issues, '4'], [MetricKey.security_hotspots, '2'], [MetricKey.coverage, '2.0%'], [MetricKey.duplicated_lines_density, '2.0%'], @@ -310,9 +310,9 @@ it('should correctly show measures for a project', async () => { const fileRow = ui.measureRow(/index\.tsx/); [ [MetricKey.ncloc, '—'], - [MetricKey.security_issues, '—'], - [MetricKey.reliability_issues, '—'], - [MetricKey.maintainability_issues, '—'], + [MetricKey.software_quality_security_issues, '—'], + [MetricKey.software_quality_reliability_issues, '—'], + [MetricKey.software_quality_maintainability_issues, '—'], [MetricKey.security_hotspots, '—'], [MetricKey.coverage, '—'], [MetricKey.duplicated_lines_density, '—'], @@ -360,9 +360,9 @@ it('should correctly show measures for a project when relying on old taxonomy', const folderRow = ui.measureRow(/folderA/); [ [MetricKey.ncloc, '2'], - [MetricKey.security_issues, '2'], - [MetricKey.reliability_issues, '2'], - [MetricKey.maintainability_issues, '2'], + [MetricKey.software_quality_security_issues, '2'], + [MetricKey.software_quality_reliability_issues, '2'], + [MetricKey.software_quality_maintainability_issues, '2'], [MetricKey.security_hotspots, '2'], [MetricKey.coverage, '2.0%'], [MetricKey.duplicated_lines_density, '2.0%'], @@ -374,9 +374,9 @@ it('should correctly show measures for a project when relying on old taxonomy', const fileRow = ui.measureRow(/index\.tsx/); [ [MetricKey.ncloc, '—'], - [MetricKey.security_issues, '—'], - [MetricKey.reliability_issues, '—'], - [MetricKey.maintainability_issues, '—'], + [MetricKey.software_quality_security_issues, '—'], + [MetricKey.software_quality_reliability_issues, '—'], + [MetricKey.software_quality_maintainability_issues, '—'], [MetricKey.security_hotspots, '—'], [MetricKey.coverage, '—'], [MetricKey.duplicated_lines_density, '—'], @@ -649,12 +649,10 @@ function generateMeasures(overallValue = '1.0', newValue = '2.0') { return keyBy( [ ...[ - MetricKey.security_issues, - MetricKey.reliability_issues, - MetricKey.maintainability_issues, - ].map((metric) => - mockMeasure({ metric, value: JSON.stringify({ total: 4 }), period: undefined }), - ), + MetricKey.software_quality_security_issues, + MetricKey.software_quality_reliability_issues, + MetricKey.software_quality_maintainability_issues, + ].map((metric) => mockMeasure({ metric, value: '4', period: undefined })), ...[ MetricKey.ncloc, MetricKey.new_lines, diff --git a/server/sonar-web/src/main/js/apps/code/__tests__/__snapshots__/utils-test.tsx.snap b/server/sonar-web/src/main/js/apps/code/__tests__/__snapshots__/utils-test.tsx.snap index 2ba88be1e1d..f71657b17db 100644 --- a/server/sonar-web/src/main/js/apps/code/__tests__/__snapshots__/utils-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/code/__tests__/__snapshots__/utils-test.tsx.snap @@ -4,9 +4,9 @@ exports[`getCodeMetrics should return the right metrics for apps 1`] = ` [ "alert_status", "ncloc", - "security_issues", - "reliability_issues", - "maintainability_issues", + "software_quality_security_issues", + "software_quality_reliability_issues", + "software_quality_maintainability_issues", "vulnerabilities", "bugs", "code_smells", @@ -96,9 +96,9 @@ exports[`getCodeMetrics should return the right metrics for portfolios 4`] = ` exports[`getCodeMetrics should return the right metrics for projects 1`] = ` [ "ncloc", - "security_issues", - "reliability_issues", - "maintainability_issues", + "software_quality_security_issues", + "software_quality_reliability_issues", + "software_quality_maintainability_issues", "vulnerabilities", "bugs", "code_smells", @@ -111,9 +111,9 @@ exports[`getCodeMetrics should return the right metrics for projects 1`] = ` exports[`getCodeMetrics should return the right metrics for projects 2`] = ` [ "new_lines", - "security_issues", - "reliability_issues", - "maintainability_issues", + "software_quality_security_issues", + "software_quality_reliability_issues", + "software_quality_maintainability_issues", "vulnerabilities", "bugs", "code_smells", diff --git a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx index 08085326415..6d9c826ab4b 100644 --- a/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx +++ b/server/sonar-web/src/main/js/apps/code/components/ComponentMeasure.tsx @@ -25,10 +25,7 @@ import { Status } from '~sonar-aligned/types/common'; import { MetricKey, MetricType } from '~sonar-aligned/types/metrics'; import RatingComponent from '../../../app/components/metrics/RatingComponent'; import { getLeakValue } from '../../../components/measure/utils'; -import { - CCT_SOFTWARE_QUALITY_METRICS, - OLD_TO_NEW_TAXONOMY_METRICS_MAP, -} from '../../../helpers/constants'; +import { OLD_TO_NEW_TAXONOMY_METRICS_MAP } from '../../../helpers/constants'; import { areCCTMeasuresComputed as areCCTMeasuresComputedFn, isDiffMetric, @@ -44,7 +41,7 @@ interface Props { metric: Metric; } -export default function ComponentMeasure(props: Props) { +export default function ComponentMeasure(props: Readonly<Props>) { const { component, metric, branchLike } = props; const isProjectLike = isProject(component.qualifier) || isApplication(component.qualifier); const { data: isStandardMode } = useStandardExperienceMode(); @@ -62,15 +59,7 @@ export default function ComponentMeasure(props: Props) { ? component.measures.find((measure) => measure.metric === finalMetricKey) : undefined; - let value; - if ( - measure?.value !== undefined && - CCT_SOFTWARE_QUALITY_METRICS.includes(measure.metric as MetricKey) - ) { - value = JSON.parse(measure.value).total; - } else { - value = isDiffMetric(metric.key) ? getLeakValue(measure) : measure?.value; - } + const value = isDiffMetric(metric.key) ? getLeakValue(measure) : measure?.value; switch (finalMetricType) { case MetricType.Level: { diff --git a/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx b/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx index 6e7255c6f67..fa486575cff 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/__tests__/ComponentMeasures-it.tsx @@ -93,11 +93,11 @@ describe('rendering', () => { // Check one of the domains. await user.click(ui.maintainabilityDomainBtn.get()); [ - 'component_measures.metric.new_maintainability_issues.name 5', + 'component_measures.metric.new_software_quality_maintainability_issues.name 5', '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.D metric.software_quality_maintainability_rating.tooltip.D.0.0%', - 'component_measures.metric.maintainability_issues.name 2', + 'component_measures.metric.software_quality_maintainability_issues.name 2', 'Technical Debt work_duration.x_minutes.1', 'Technical Debt Ratio 1.0%', 'Maintainability Rating metric.has_rating_X.D metric.software_quality_maintainability_rating.tooltip.D.0.0%', @@ -148,8 +148,14 @@ describe('rendering', () => { }); it('should correctly revert to old measures when analysis is missing', async () => { - measuresHandler.deleteComponentMeasure('foo', MetricKey.maintainability_issues); - measuresHandler.deleteComponentMeasure('foo', MetricKey.new_maintainability_issues); + measuresHandler.deleteComponentMeasure( + 'foo', + MetricKey.software_quality_maintainability_issues, + ); + measuresHandler.deleteComponentMeasure( + 'foo', + MetricKey.new_software_quality_maintainability_issues, + ); measuresHandler.deleteComponentMeasure( 'foo', MetricKey.software_quality_maintainability_rating, @@ -198,11 +204,11 @@ describe('rendering', () => { // Check one of the domains. await user.click(ui.maintainabilityDomainBtn.get()); [ - 'component_measures.metric.new_maintainability_issues.name 5', + 'component_measures.metric.new_software_quality_maintainability_issues.name 5', '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', + 'component_measures.metric.software_quality_maintainability_issues.name 2', '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%', @@ -438,16 +444,20 @@ describe('rendering', () => { it('should correctly render a link to the activity page', async () => { const { ui, user } = getPageObject(); - renderMeasuresApp('component_measures?id=foo&metric=new_maintainability_issues'); + renderMeasuresApp( + 'component_measures?id=foo&metric=new_software_quality_maintainability_issues', + ); await ui.appLoaded(); expect(ui.goToActivityLink.query()).not.toBeInTheDocument(); await user.click( - ui.measureLink('component_measures.metric.maintainability_issues.name 2').get(), + ui + .measureLink('component_measures.metric.software_quality_maintainability_issues.name 2') + .get(), ); expect(ui.goToActivityLink.get()).toHaveAttribute( 'href', - '/project/activity?id=foo&graph=custom&custom_metrics=maintainability_issues', + '/project/activity?id=foo&graph=custom&custom_metrics=software_quality_maintainability_issues', ); }); @@ -479,7 +489,9 @@ describe('navigation', () => { await user.click(ui.maintainabilityDomainBtn.get()); await user.click( - ui.measureLink('component_measures.metric.maintainability_issues.name 2').get(), + ui + .measureLink('component_measures.metric.software_quality_maintainability_issues.name 2') + .get(), ); expect( within(ui.measuresRow('folderA').get()).getByRole('cell', { name: '2' }), @@ -512,7 +524,9 @@ describe('navigation', () => { await user.click(ui.maintainabilityDomainBtn.get()); await user.click( - ui.measureLink('component_measures.metric.maintainability_issues.name 2').get(), + ui + .measureLink('component_measures.metric.software_quality_maintainability_issues.name 2') + .get(), ); // Click list option in view select @@ -568,7 +582,9 @@ describe('navigation', () => { // Drilldown to the file level. await user.click(ui.maintainabilityDomainBtn.get()); await user.click( - ui.measureLink('component_measures.metric.maintainability_issues.name 2').get(), + ui + .measureLink('component_measures.metric.software_quality_maintainability_issues.name 2') + .get(), ); await ui.arrowDown(); // Select the 1st element ("folderA") @@ -608,8 +624,14 @@ describe('redirects', () => { }); it('should redirect old metric route', async () => { - measuresHandler.deleteComponentMeasure('foo', MetricKey.maintainability_issues); - measuresHandler.deleteComponentMeasure('foo', MetricKey.new_maintainability_issues); + measuresHandler.deleteComponentMeasure( + 'foo', + MetricKey.software_quality_maintainability_issues, + ); + measuresHandler.deleteComponentMeasure( + 'foo', + MetricKey.new_software_quality_maintainability_issues, + ); const { ui } = getPageObject(); renderMeasuresApp('component_measures/metric/bugs?id=foo'); @@ -625,13 +647,19 @@ describe('redirects', () => { renderMeasuresApp('component_measures/metric/security_issues?id=foo'); await ui.appLoaded(); expect( - ui.measureLink('component_measures.metric.security_issues.name 1').get(), + ui.measureLink('component_measures.metric.software_quality_security_issues.name 1').get(), ).toHaveAttribute('aria-current', 'true'); }); it('should redirect old domain route', async () => { - measuresHandler.deleteComponentMeasure('foo', MetricKey.maintainability_issues); - measuresHandler.deleteComponentMeasure('foo', MetricKey.new_maintainability_issues); + measuresHandler.deleteComponentMeasure( + 'foo', + MetricKey.software_quality_maintainability_issues, + ); + measuresHandler.deleteComponentMeasure( + 'foo', + MetricKey.new_software_quality_maintainability_issues, + ); const { ui } = getPageObject(); renderMeasuresApp('component_measures/domain/bugs?id=foo'); diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx index 70980a390dd..9ebb24a2e5a 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/components/MeasureContent.tsx @@ -31,7 +31,7 @@ import { getComponentMeasureUniqueKey } from '../../../helpers/component'; import { SOFTWARE_QUALITY_RATING_METRICS_MAP } from '../../../helpers/constants'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { translate } from '../../../helpers/l10n'; -import { getCCTMeasureValue, isDiffMetric } from '../../../helpers/measures'; +import { isDiffMetric } from '../../../helpers/measures'; import { RequestData } from '../../../helpers/request'; import { isDefined } from '../../../helpers/types'; import { getProjectUrl } from '../../../helpers/urls'; @@ -134,9 +134,8 @@ export default function MeasureContent(props: Readonly<Props>) { const measures = measuresData?.component.measures ?? []; const measure = measures.find((m) => m.metric === requestedMetric.key); const secondaryMeasure = measures.find((m) => m.metric !== requestedMetric.key); - const rawMeasureValue = + const measureValue = measure && (isDiffMetric(measure.metric) ? measure.period?.value : measure.value); - const measureValue = getCCTMeasureValue(metric.key, rawMeasureValue); const isFileComponent = isFile(baseComponent.qualifier); const paging = treeData?.pages[treeData?.pages.length - 1].paging; diff --git a/server/sonar-web/src/main/js/apps/component-measures/config/bubbles.ts b/server/sonar-web/src/main/js/apps/component-measures/config/bubbles.ts index a63963f7b09..703b6003f12 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/config/bubbles.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/config/bubbles.ts @@ -35,19 +35,19 @@ export const newTaxonomyBubbles: BubblesByDomain = { Reliability: { x: MetricKey.ncloc, y: MetricKey.software_quality_reliability_remediation_effort, - size: MetricKey.reliability_issues, + size: MetricKey.software_quality_reliability_issues, colors: [MetricKey.software_quality_reliability_rating], }, Security: { x: MetricKey.ncloc, y: MetricKey.software_quality_security_remediation_effort, - size: MetricKey.security_issues, + size: MetricKey.software_quality_security_issues, colors: [MetricKey.software_quality_security_rating], }, Maintainability: { x: MetricKey.ncloc, y: MetricKey.software_quality_maintainability_remediation_effort, - size: MetricKey.maintainability_issues, + size: MetricKey.software_quality_maintainability_issues, colors: [MetricKey.software_quality_maintainability_rating], }, Coverage: { @@ -77,19 +77,19 @@ export const newTaxonomyWithoutRatingsBubbles: BubblesByDomain = { Reliability: { x: MetricKey.ncloc, y: MetricKey.reliability_remediation_effort, - size: MetricKey.reliability_issues, + size: MetricKey.software_quality_reliability_issues, colors: [MetricKey.reliability_rating], }, Security: { x: MetricKey.ncloc, y: MetricKey.security_remediation_effort, - size: MetricKey.security_issues, + size: MetricKey.software_quality_security_issues, colors: [MetricKey.security_rating], }, Maintainability: { x: MetricKey.ncloc, y: MetricKey.sqale_index, - size: MetricKey.maintainability_issues, + size: MetricKey.software_quality_maintainability_issues, colors: [MetricKey.sqale_rating], }, Coverage: { diff --git a/server/sonar-web/src/main/js/apps/component-measures/config/domains.ts b/server/sonar-web/src/main/js/apps/component-measures/config/domains.ts index 93db7f74622..aebad3521f4 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/config/domains.ts +++ b/server/sonar-web/src/main/js/apps/component-measures/config/domains.ts @@ -33,7 +33,7 @@ export const domains: Domains = { categories: [NEW_CODE_CATEGORY, OVERALL_CATEGORY], order: [ NEW_CODE_CATEGORY, - MetricKey.new_reliability_issues, + MetricKey.new_software_quality_reliability_issues, MetricKey.new_bugs, MetricKey.new_reliability_rating, SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_reliability_rating], @@ -41,7 +41,7 @@ export const domains: Domains = { SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_reliability_remediation_effort], OVERALL_CATEGORY, - MetricKey.reliability_issues, + MetricKey.software_quality_reliability_issues, MetricKey.bugs, MetricKey.reliability_rating, SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.reliability_rating], @@ -54,7 +54,7 @@ export const domains: Domains = { categories: [NEW_CODE_CATEGORY, OVERALL_CATEGORY], order: [ NEW_CODE_CATEGORY, - MetricKey.new_security_issues, + MetricKey.new_software_quality_security_issues, MetricKey.new_vulnerabilities, MetricKey.new_security_rating, SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_security_rating], @@ -62,7 +62,7 @@ export const domains: Domains = { SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_security_remediation_effort], OVERALL_CATEGORY, - MetricKey.security_issues, + MetricKey.software_quality_security_issues, MetricKey.vulnerabilities, MetricKey.security_rating, SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.security_rating], @@ -92,7 +92,7 @@ export const domains: Domains = { categories: [NEW_CODE_CATEGORY, OVERALL_CATEGORY], order: [ NEW_CODE_CATEGORY, - MetricKey.new_maintainability_issues, + MetricKey.new_software_quality_maintainability_issues, MetricKey.new_code_smells, MetricKey.new_technical_debt, SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_technical_debt], @@ -102,7 +102,7 @@ export const domains: Domains = { SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.new_maintainability_rating], OVERALL_CATEGORY, - MetricKey.maintainability_issues, + MetricKey.software_quality_maintainability_issues, MetricKey.code_smells, MetricKey.sqale_index, SOFTWARE_QUALITY_RATING_METRICS_MAP[MetricKey.sqale_index], @@ -177,11 +177,16 @@ export const domains: Domains = { }, Complexity: { - order: ['complexity', 'function_complexity', 'file_complexity', 'class_complexity'], + order: [ + MetricKey.complexity, + MetricKey.function_complexity, + MetricKey.file_complexity, + MetricKey.class_complexity, + ], }, Releasability: { - order: ['releasability_rating', 'releasability_effort', 'alert_status'], + order: [MetricKey.releasability_rating, MetricKey.releasability_effort, MetricKey.alert_status], }, Issues: { diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChartView.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChartView.tsx index 1107b0a116a..7751fc840a4 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChartView.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/BubbleChartView.tsx @@ -39,7 +39,7 @@ import { translate, translateWithParameters, } from '../../../helpers/l10n'; -import { getCCTMeasureValue, isDiffMetric } from '../../../helpers/measures'; +import { isDiffMetric } from '../../../helpers/measures'; import { isDefined } from '../../../helpers/types'; import { getComponentDrilldownUrl } from '../../../helpers/urls'; import { BranchLike } from '../../../types/branch-like'; @@ -257,9 +257,7 @@ const getMeasureVal = (component: ComponentMeasureEnhanced, metric: Metric) => { if (!measure) { return undefined; } - return Number( - getCCTMeasureValue(metric.key, isDiffMetric(metric.key) ? measure.leak : measure.value), - ); + return Number(isDiffMetric(metric.key) ? measure.leak : measure.value); }; const getTooltip = ( diff --git a/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx b/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx index e4661f2acb2..b34c2e24004 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/drilldown/MeasureCell.tsx @@ -20,7 +20,7 @@ import { NumericalCell } from '~design-system'; import Measure from '~sonar-aligned/components/measure/Measure'; -import { getCCTMeasureValue, isDiffMetric } from '../../../helpers/measures'; +import { isDiffMetric } from '../../../helpers/measures'; import { BranchLike } from '../../../types/branch-like'; import { ComponentMeasureEnhanced, MeasureEnhanced, Metric } from '../../../types/types'; @@ -35,8 +35,7 @@ export default function MeasureCell({ component, measure, metric, branchLike }: const getValue = (item: { leak?: string; value?: string }) => isDiffMetric(metric.key) ? item.leak : item.value; - const rawValue = getValue(measure || component); - const value = getCCTMeasureValue(metric.key, rawValue); + const value = getValue(measure || component); return ( <NumericalCell className="sw-py-3"> diff --git a/server/sonar-web/src/main/js/apps/component-measures/routes.tsx b/server/sonar-web/src/main/js/apps/component-measures/routes.tsx index bd5fc98bf99..7b640397127 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/routes.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/routes.tsx @@ -21,7 +21,9 @@ import { Navigate, Route, useParams, useSearchParams } from 'react-router-dom'; import { lazyLoadComponent } from '~sonar-aligned/helpers/lazyLoadComponent'; import { searchParamsToQuery } from '~sonar-aligned/helpers/router'; +import { MetricKey } from '~sonar-aligned/types/metrics'; import NavigateWithParams from '../../app/utils/NavigateWithParams'; +import { SOFTWARE_QUALITIES_ISSUES_KEYS_MAP } from '../../helpers/constants'; import { omitNil } from '../../helpers/request'; const ComponentMeasuresApp = lazyLoadComponent(() => import('./components/ComponentMeasuresApp')); @@ -36,7 +38,9 @@ const routes = () => ( pathname="/component_measures" transformParams={(params) => omitNil({ - metric: params['domainName'], + metric: + SOFTWARE_QUALITIES_ISSUES_KEYS_MAP[params['domainName'] as MetricKey] ?? + params['domainName'], }) } /> @@ -70,7 +74,8 @@ function MetricRedirect() { search: new URLSearchParams( omitNil({ ...searchParamsToQuery(searchParams), - metric: params.metricKey, + metric: + SOFTWARE_QUALITIES_ISSUES_KEYS_MAP[params.metricKey as MetricKey] ?? params.metricKey, view: params.view, }), ).toString(), diff --git a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx index a2c7f0a950f..b38402ae671 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx +++ b/server/sonar-web/src/main/js/apps/component-measures/sidebar/Sidebar.tsx @@ -36,7 +36,7 @@ import useFollowScroll from '../../../hooks/useFollowScroll'; import { useStandardExperienceMode } from '../../../queries/settings'; import { Domain } from '../../../types/measures'; import { MeasureEnhanced } from '../../../types/types'; -import { PROJECT_OVERVEW, Query, isProjectOverview, populateDomainsFromMeasures } from '../utils'; +import { PROJECT_OVERVIEW, Query, isProjectOverview, populateDomainsFromMeasures } from '../utils'; import DomainSubnavigation from './DomainSubnavigation'; interface Props { @@ -61,7 +61,7 @@ export default function Sidebar(props: Readonly<Props>) { ); const handleProjectOverviewClick = () => { - handleChangeMetric(PROJECT_OVERVEW); + handleChangeMetric(PROJECT_OVERVIEW); }; const distanceFromBottom = topScroll + window.innerHeight - document.body.scrollHeight; @@ -97,7 +97,7 @@ export default function Sidebar(props: Readonly<Props>) { ariaCurrent={isProjectOverview(selectedMetric)} onClick={handleProjectOverviewClick} > - {translate('component_measures.overview', PROJECT_OVERVEW, 'subnavigation')} + {translate('component_measures.overview', PROJECT_OVERVIEW, 'subnavigation')} </SubnavigationItem> </SubnavigationGroup> 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 c4defaf8727..037d0b454f0 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 @@ -39,7 +39,6 @@ import { areCCTMeasuresComputed, areLeakCCTMeasuresComputed, areSoftwareQualityRatingsComputed, - getCCTMeasureValue, getDisplayMetrics, isDiffMetric, MEASURES_REDIRECTION, @@ -64,9 +63,9 @@ import { BubblesByDomain } from './config/bubbles'; import { domains } from './config/domains'; export const BUBBLES_FETCH_LIMIT = 500; -export const PROJECT_OVERVEW = 'project_overview'; +export const PROJECT_OVERVIEW = 'project_overview'; export const DEFAULT_VIEW = MeasurePageView.tree; -export const DEFAULT_METRIC = PROJECT_OVERVEW; +export const DEFAULT_METRIC = PROJECT_OVERVIEW; export const KNOWN_DOMAINS = [ 'Releasability', 'Security', @@ -108,10 +107,7 @@ export const populateDomainsFromMeasures = memoize( .filter((measure) => !DEPRECATED_METRICS.includes(measure.metric.key as MetricKey)) .map((measure) => { const isDiff = isDiffMetric(measure.metric.key); - const calculatedValue = getCCTMeasureValue( - measure.metric.key, - isDiff ? measure.leak : measure.value, - ); + const calculatedValue = isDiff ? measure.leak : measure.value; return { ...measure, @@ -328,7 +324,7 @@ export function getBubbleYDomain(bubblesByDomain: BubblesByDomain, domain: strin } export function isProjectOverview(metric: string) { - return metric === PROJECT_OVERVEW; + return metric === PROJECT_OVERVIEW; } function parseView(metric: MetricKey, rawView?: string): MeasurePageView { diff --git a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx index 694dd594eaa..33cea6fd02b 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/SoftwareImpactMeasureCard.tsx @@ -33,7 +33,7 @@ import { import { isDefined } from '../../../helpers/types'; import { useStandardExperienceMode } from '../../../queries/settings'; import { Branch } from '../../../types/branch-like'; -import { SoftwareImpactMeasureData, SoftwareQuality } from '../../../types/clean-code-taxonomy'; +import { SoftwareQuality } from '../../../types/clean-code-taxonomy'; import { QualityGateStatusConditionEnhanced } from '../../../types/quality-gates'; import { Component, MeasureEnhanced } from '../../../types/types'; import { Status, softwareQualityToMeasure } from '../utils'; @@ -56,15 +56,11 @@ export function SoftwareImpactMeasureCard(props: Readonly<SoftwareImpactBreakdow // Find measure for this software quality const metricKey = softwareQualityToMeasure(softwareQuality); - const measureRaw = measures.find((m) => m.metric.key === metricKey); - const measure = isStandardMode - ? undefined - : (JSON.parse(measureRaw?.value ?? 'null') as SoftwareImpactMeasureData); + const measure = isStandardMode ? undefined : measures.find((m) => m.metric.key === metricKey); const alternativeMeasure = measures.find( (m) => m.metric.key === SOFTWARE_QUALITIES_METRIC_KEYS_MAP[softwareQuality].deprecatedMetric, ); - - const count = formatMeasure(measure?.total ?? alternativeMeasure?.value, MetricType.ShortInteger); + const count = formatMeasure(measure?.value ?? alternativeMeasure?.value, MetricType.ShortInteger); const totalLinkHref = getComponentIssuesUrl(component.key, { ...DEFAULT_ISSUES_QUERY, diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx index 8fe0b15c627..1f0cdf03650 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/BranchOverview-it.tsx @@ -351,14 +351,17 @@ describe('project overview', () => { it('should render old measures if software impact are missing', async () => { // Make as if new analysis after upgrade is missing - measuresHandler.deleteComponentMeasure('foo', MetricKey.maintainability_issues); + measuresHandler.deleteComponentMeasure( + 'foo', + MetricKey.software_quality_maintainability_issues, + ); measuresHandler.deleteComponentMeasure( 'foo', MetricKey.software_quality_maintainability_rating, ); - measuresHandler.deleteComponentMeasure('foo', MetricKey.security_issues); + measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_security_issues); measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_security_rating); - measuresHandler.deleteComponentMeasure('foo', MetricKey.reliability_issues); + measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_reliability_issues); measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_reliability_rating); const { user, ui } = getPageObjects(); @@ -390,18 +393,21 @@ describe('project overview', () => { it('should render missing software impact measure cards if both software qualities and old measures are missing', async () => { // Make as if no measures at all - measuresHandler.deleteComponentMeasure('foo', MetricKey.maintainability_issues); + measuresHandler.deleteComponentMeasure( + 'foo', + MetricKey.software_quality_maintainability_issues, + ); measuresHandler.deleteComponentMeasure('foo', MetricKey.code_smells); measuresHandler.deleteComponentMeasure( 'foo', MetricKey.software_quality_maintainability_rating, ); - measuresHandler.deleteComponentMeasure('foo', MetricKey.security_issues); + measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_security_issues); measuresHandler.deleteComponentMeasure('foo', MetricKey.vulnerabilities); measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_security_rating); - measuresHandler.deleteComponentMeasure('foo', MetricKey.reliability_issues); + measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_reliability_issues); measuresHandler.deleteComponentMeasure('foo', MetricKey.bugs); measuresHandler.deleteComponentMeasure('foo', MetricKey.software_quality_reliability_rating); @@ -431,13 +437,13 @@ describe('project overview', () => { }); it.each([ - ['security_issues', MetricKey.security_issues], - ['reliability_issues', MetricKey.reliability_issues], - ['maintainability_issues', MetricKey.maintainability_issues], + [MetricKey.software_quality_security_issues], + [MetricKey.software_quality_reliability_issues], + [MetricKey.software_quality_maintainability_issues], ])( 'should display info about missing analysis if a project is not computed for %s', async (missingMetricKey) => { - measuresHandler.deleteComponentMeasure('foo', missingMetricKey as MetricKey); + measuresHandler.deleteComponentMeasure('foo', missingMetricKey); const { user, ui } = getPageObjects(); renderBranchOverview(); @@ -723,9 +729,9 @@ describe('application overview', () => { }); it.each([ - ['security_issues', MetricKey.security_issues], - ['reliability_issues', MetricKey.reliability_issues], - ['maintainability_issues', MetricKey.maintainability_issues], + [MetricKey.software_quality_security_issues], + [MetricKey.software_quality_reliability_issues], + [MetricKey.software_quality_maintainability_issues], ])( 'should ask to reanalyze all projects if a project is not computed for %s', async (missingMetricKey) => { 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 6ddb82ea2c1..4fb159fbfb6 100644 --- a/server/sonar-web/src/main/js/apps/overview/utils.tsx +++ b/server/sonar-web/src/main/js/apps/overview/utils.tsx @@ -42,9 +42,9 @@ export const BRANCH_OVERVIEW_METRICS: string[] = [ MetricKey.accepted_issues, MetricKey.new_accepted_issues, MetricKey.high_impact_accepted_issues, - MetricKey.maintainability_issues, - MetricKey.reliability_issues, - MetricKey.security_issues, + MetricKey.software_quality_maintainability_issues, + MetricKey.software_quality_reliability_issues, + MetricKey.software_quality_security_issues, // bugs MetricKey.bugs, @@ -190,7 +190,7 @@ export const METRICS_REPORTED_IN_OVERVIEW_CARDS = [ ]; export function softwareQualityToMeasure(softwareQuality: SoftwareQuality): MetricKey { - return (softwareQuality.toLowerCase() + '_issues') as MetricKey; + return `software_quality_${softwareQuality.toLowerCase()}_issues` as MetricKey; } export function getIssueRatingName(type: IssueType) { diff --git a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx index b74a5f34e96..380572a181c 100644 --- a/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/projectActivity/components/__tests__/ProjectActivityApp-it.tsx @@ -90,7 +90,7 @@ beforeEach(() => { MetricKey.sqale_rating, MetricKey.security_hotspots_reviewed, MetricKey.security_review_rating, - MetricKey.maintainability_issues, + MetricKey.software_quality_maintainability_issues, ].map((metric) => mockMeasureHistory({ metric, diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx index 7aeadbb197f..9ea67fc2774 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCard.tsx @@ -68,9 +68,9 @@ function renderFirstLine( ) { const { analysisDate, isFavorite, key, measures, name, qualifier, tags, visibility } = project; const noSoftwareQualityMetrics = [ - MetricKey.reliability_issues, - MetricKey.maintainability_issues, - MetricKey.security_issues, + MetricKey.software_quality_reliability_issues, + MetricKey.software_quality_maintainability_issues, + MetricKey.software_quality_security_issues, ].every((key) => measures[key] === undefined); const noRatingMetrics = [ MetricKey.software_quality_reliability_rating, diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx index 07822ead3ff..c5d02505150 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/ProjectCardMeasures.tsx @@ -125,35 +125,36 @@ function renderRatings(props: ProjectCardMeasuresProps, isStandardMode: boolean) : [ { iconLabel: translate( - `metric.${isStandardMode ? MetricKey.vulnerabilities : MetricKey.security_issues}.short_name`, + `metric.${isStandardMode ? MetricKey.vulnerabilities : MetricKey.software_quality_security_issues}.short_name`, ), noShrink: true, metricKey: - isStandardMode || measures[MetricKey.security_issues] === undefined + isStandardMode || measures[MetricKey.software_quality_security_issues] === undefined ? MetricKey.vulnerabilities - : MetricKey.security_issues, + : MetricKey.software_quality_security_issues, metricRatingKey: MetricKey.security_rating, metricType: MetricType.ShortInteger, }, { iconLabel: translate( - `metric.${isStandardMode ? MetricKey.bugs : MetricKey.reliability_issues}.short_name`, + `metric.${isStandardMode ? MetricKey.bugs : MetricKey.software_quality_reliability_issues}.short_name`, ), metricKey: - isStandardMode || measures[MetricKey.reliability_issues] === undefined + isStandardMode || measures[MetricKey.software_quality_reliability_issues] === undefined ? MetricKey.bugs - : MetricKey.reliability_issues, + : MetricKey.software_quality_reliability_issues, metricRatingKey: MetricKey.reliability_rating, metricType: MetricType.ShortInteger, }, { iconLabel: translate( - `metric.${isStandardMode ? MetricKey.code_smells : MetricKey.maintainability_issues}.short_name`, + `metric.${isStandardMode ? MetricKey.code_smells : MetricKey.software_quality_maintainability_issues}.short_name`, ), metricKey: - isStandardMode || measures[MetricKey.maintainability_issues] === undefined + isStandardMode || + measures[MetricKey.software_quality_maintainability_issues] === undefined ? MetricKey.code_smells - : MetricKey.maintainability_issues, + : MetricKey.software_quality_maintainability_issues, metricRatingKey: MetricKey.sqale_rating, metricType: MetricType.ShortInteger, }, @@ -162,7 +163,7 @@ function renderRatings(props: ProjectCardMeasuresProps, isStandardMode: boolean) const measureList = [ ...measuresByCodeLeak, { - iconKey: 'security_hotspots', + iconKey: MetricKey.security_hotspots, iconLabel: translate('projects.security_hotspots_reviewed'), metricKey: isNewCode ? MetricKey.new_security_hotspots_reviewed @@ -177,15 +178,6 @@ function renderRatings(props: ProjectCardMeasuresProps, isStandardMode: boolean) return measureList.map((measure) => { const { iconLabel, metricKey, metricRatingKey, metricType } = measure; - const measureValue = - [ - MetricKey.security_issues, - MetricKey.reliability_issues, - MetricKey.maintainability_issues, - ].includes(metricKey) && measures[metricKey] - ? JSON.parse(measures[metricKey] as string)?.total - : measures[metricKey]; - return ( <ProjectCardMeasure key={metricKey} metricKey={metricKey} label={iconLabel}> <RatingComponent ratingMetric={metricRatingKey} componentKey={componentKey} /> @@ -193,7 +185,7 @@ function renderRatings(props: ProjectCardMeasuresProps, isStandardMode: boolean) componentKey={componentKey} metricKey={metricKey} metricType={metricType} - value={measureValue} + value={measures[metricKey]} className="sw-ml-2 sw-typo-lg-semibold" /> </ProjectCardMeasure> diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx index 0927cc2a567..93ae42ebbd2 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCard-test.tsx @@ -188,14 +188,9 @@ describe('upgrade scenario (awaiting scan)', () => { ...PROJECT, measures: { ...MEASURES, - [MetricKey.security_issues]: JSON.stringify({ LOW: 0, MEDIUM: 0, HIGH: 1, total: 1 }), - [MetricKey.reliability_issues]: JSON.stringify({ LOW: 0, MEDIUM: 2, HIGH: 0, total: 2 }), - [MetricKey.maintainability_issues]: JSON.stringify({ - LOW: 3, - MEDIUM: 0, - HIGH: 0, - total: 3, - }), + [MetricKey.software_quality_security_issues]: '1', + [MetricKey.software_quality_reliability_issues]: '2', + [MetricKey.software_quality_maintainability_issues]: '3', [MetricKey.software_quality_maintainability_rating]: '2', [MetricKey.software_quality_reliability_rating]: '2', [MetricKey.software_quality_security_rating]: '2', @@ -242,14 +237,9 @@ describe('upgrade scenario (awaiting scan)', () => { ...PROJECT, measures: { ...MEASURES, - [MetricKey.security_issues]: JSON.stringify({ LOW: 0, MEDIUM: 0, HIGH: 1, total: 1 }), - [MetricKey.reliability_issues]: JSON.stringify({ LOW: 0, MEDIUM: 2, HIGH: 0, total: 2 }), - [MetricKey.maintainability_issues]: JSON.stringify({ - LOW: 3, - MEDIUM: 0, - HIGH: 0, - total: 3, - }), + [MetricKey.software_quality_security_issues]: '1', + [MetricKey.software_quality_reliability_issues]: '2', + [MetricKey.software_quality_maintainability_issues]: '3', [MetricKey.code_smells]: '4', [MetricKey.bugs]: '5', [MetricKey.vulnerabilities]: '6', @@ -340,14 +330,9 @@ describe('upgrade scenario (awaiting scan)', () => { ...PROJECT, measures: { ...MEASURES, - [MetricKey.security_issues]: JSON.stringify({ LOW: 0, MEDIUM: 0, HIGH: 1, total: 1 }), - [MetricKey.reliability_issues]: JSON.stringify({ LOW: 0, MEDIUM: 2, HIGH: 0, total: 2 }), - [MetricKey.maintainability_issues]: JSON.stringify({ - LOW: 3, - MEDIUM: 0, - HIGH: 0, - total: 3, - }), + [MetricKey.software_quality_security_issues]: '1', + [MetricKey.software_quality_reliability_issues]: '2', + [MetricKey.software_quality_maintainability_issues]: '3', [MetricKey.software_quality_maintainability_rating]: '2', [MetricKey.software_quality_reliability_rating]: '2', [MetricKey.software_quality_security_rating]: '2', diff --git a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx index bbaaa1391f8..a18321c8f8b 100644 --- a/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx +++ b/server/sonar-web/src/main/js/apps/projects/components/project-card/__tests__/ProjectCardMeasures-test.tsx @@ -42,9 +42,15 @@ beforeEach(() => { describe('Overall measures', () => { it('should be rendered properly', async () => { renderProjectCardMeasures(); - expect(await screen.findByTitle('metric.security_issues.short_name')).toBeInTheDocument(); - expect(screen.getByTitle('metric.reliability_issues.short_name')).toBeInTheDocument(); - expect(screen.getByTitle('metric.maintainability_issues.short_name')).toBeInTheDocument(); + expect( + await screen.findByTitle('metric.software_quality_security_issues.short_name'), + ).toBeInTheDocument(); + expect( + screen.getByTitle('metric.software_quality_reliability_issues.short_name'), + ).toBeInTheDocument(); + expect( + screen.getByTitle('metric.software_quality_maintainability_issues.short_name'), + ).toBeInTheDocument(); expect(screen.queryByTitle('metric.vulnerabilities.short_name')).not.toBeInTheDocument(); expect(screen.queryByTitle('metric.bugs.short_name')).not.toBeInTheDocument(); expect(screen.queryByTitle('metric.code_smells.short_name')).not.toBeInTheDocument(); @@ -56,9 +62,15 @@ describe('Overall measures', () => { expect(await screen.findByTitle('metric.vulnerabilities.short_name')).toBeInTheDocument(); expect(screen.getByTitle('metric.bugs.short_name')).toBeInTheDocument(); expect(screen.getByTitle('metric.code_smells.short_name')).toBeInTheDocument(); - expect(screen.queryByTitle('metric.security_issues.short_name')).not.toBeInTheDocument(); - expect(screen.queryByTitle('metric.reliability_issues.short_name')).not.toBeInTheDocument(); - expect(screen.queryByTitle('metric.maintainability_issues.short_name')).not.toBeInTheDocument(); + expect( + screen.queryByTitle('metric.software_quality_security_issues.short_name'), + ).not.toBeInTheDocument(); + expect( + screen.queryByTitle('metric.software_quality_software_quality_reliability_issues.short_name'), + ).not.toBeInTheDocument(); + expect( + screen.queryByTitle('metric.software_quality_maintainability_issues.short_name'), + ).not.toBeInTheDocument(); }); it("should be not be rendered if there's no line of code", () => { @@ -92,9 +104,9 @@ function renderProjectCardMeasures( [MetricKey.code_smells]: '132', [MetricKey.coverage]: '88.3', [MetricKey.duplicated_lines_density]: '9.8', - [MetricKey.maintainability_issues]: JSON.stringify({ total: 10 }), - [MetricKey.reliability_issues]: JSON.stringify({ total: 10 }), - [MetricKey.security_issues]: JSON.stringify({ total: 10 }), + [MetricKey.software_quality_maintainability_issues]: '10', + [MetricKey.software_quality_reliability_issues]: '10', + [MetricKey.software_quality_security_issues]: '10', [MetricKey.ncloc]: '2053', [MetricKey.reliability_rating]: '1.0', [MetricKey.security_rating]: '1.0', diff --git a/server/sonar-web/src/main/js/apps/projects/utils.ts b/server/sonar-web/src/main/js/apps/projects/utils.ts index 8cafffbc8e3..3f0630b43fa 100644 --- a/server/sonar-web/src/main/js/apps/projects/utils.ts +++ b/server/sonar-web/src/main/js/apps/projects/utils.ts @@ -89,15 +89,15 @@ const PAGE_SIZE = 50; export const METRICS = [ MetricKey.alert_status, - MetricKey.reliability_issues, + MetricKey.software_quality_reliability_issues, MetricKey.bugs, MetricKey.reliability_rating, MetricKey.software_quality_reliability_rating, - MetricKey.security_issues, + MetricKey.software_quality_security_issues, MetricKey.vulnerabilities, MetricKey.security_rating, MetricKey.software_quality_security_rating, - MetricKey.maintainability_issues, + MetricKey.software_quality_maintainability_issues, MetricKey.code_smells, MetricKey.sqale_rating, MetricKey.software_quality_maintainability_rating, diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx index 4f74bc8ede3..54e36c96443 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerHeader.tsx @@ -100,9 +100,7 @@ export default function SourceViewerHeader(props: Readonly<Props>) { const measure = componentMeasures.find( (m) => m.metric === (areCCTMeasuresComputed ? metric : deprecatedMetric), ); - const measureValue = areCCTMeasuresComputed - ? JSON.parse(measure?.value ?? 'null').total - : (measure?.value ?? 0); + const measureValue = measure?.value ?? 0; const linkUrl = getComponentIssuesUrl(project, { ...getBranchLikeQuery(branchLike), diff --git a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx index a1b5a0a8657..d2a9dc2c0ff 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/__tests__/SourceViewer-it.tsx @@ -345,14 +345,18 @@ it('should show software quality measures in header', async () => { renderSourceViewer({ componentMeasures: generateMeasures(), showMeasures: true }); expect( - await byLabelText('source_viewer.issue_link_x.3.metric.security_issues.short_name').find(), + await byLabelText( + 'source_viewer.issue_link_x.3.metric.software_quality_security_issues.short_name', + ).find(), ).toBeInTheDocument(); expect( - await byLabelText('source_viewer.issue_link_x.3.metric.reliability_issues.short_name').find(), + await byLabelText( + 'source_viewer.issue_link_x.3.metric.software_quality_reliability_issues.short_name', + ).find(), ).toBeInTheDocument(); expect( await byLabelText( - 'source_viewer.issue_link_x.3.metric.maintainability_issues.short_name', + 'source_viewer.issue_link_x.3.metric.software_quality_maintainability_issues.short_name', ).find(), ).toBeInTheDocument(); }); @@ -366,14 +370,18 @@ it('should show old issue measures in header', async () => { }); expect( - await byLabelText('source_viewer.issue_link_x.1.metric.security_issues.short_name').find(), + await byLabelText( + 'source_viewer.issue_link_x.1.metric.software_quality_security_issues.short_name', + ).find(), ).toBeInTheDocument(); expect( - await byLabelText('source_viewer.issue_link_x.1.metric.reliability_issues.short_name').find(), + await byLabelText( + 'source_viewer.issue_link_x.1.metric.software_quality_reliability_issues.short_name', + ).find(), ).toBeInTheDocument(); expect( await byLabelText( - 'source_viewer.issue_link_x.1.metric.maintainability_issues.short_name', + 'source_viewer.issue_link_x.1.metric.software_quality_maintainability_issues.short_name', ).find(), ).toBeInTheDocument(); }); @@ -396,12 +404,10 @@ it('should show correct message when component does not exist', async () => { function generateMeasures(qualitiesValue = '3.0', overallValue = '1.0', newValue = '2.0') { return [ ...[ - MetricKey.security_issues, - MetricKey.reliability_issues, - MetricKey.maintainability_issues, - ].map((metric) => - mockMeasure({ metric, value: JSON.stringify({ total: qualitiesValue }), period: undefined }), - ), + MetricKey.software_quality_security_issues, + MetricKey.software_quality_reliability_issues, + MetricKey.software_quality_maintainability_issues, + ].map((metric) => mockMeasure({ metric, value: qualitiesValue, period: undefined })), ...[ MetricKey.ncloc, MetricKey.new_lines, diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/ActivityGraph-it.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/ActivityGraph-it.tsx index e144fcf2929..5e76f3e45c8 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/ActivityGraph-it.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/ActivityGraph-it.tsx @@ -55,7 +55,7 @@ describe('rendering', () => { }); it.each([ - ['MQR', 'true', MetricKey.maintainability_issues], + ['MQR', 'true', MetricKey.software_quality_maintainability_issues], ['Standard', 'false', MetricKey.code_smells], ])('should show the correct legend items in %s mode', async (_, mode, metric) => { settingsHandler.set(SettingsKey.MQRMode, mode); @@ -125,9 +125,9 @@ it.each([ [ 'MQR', 'true', - MetricKey.reliability_issues, - MetricKey.maintainability_issues, - MetricKey.security_issues, + MetricKey.software_quality_reliability_issues, + MetricKey.software_quality_maintainability_issues, + MetricKey.software_quality_security_issues, ], ['Standard', 'false', MetricKey.bugs, MetricKey.code_smells, MetricKey.vulnerabilities], ])( @@ -204,7 +204,9 @@ function getPageObject() { // Add/remove metrics. addMetricBtn: byRole('button', { name: 'project_activity.graphs.custom.add' }), - maintainabilityIssuesCheckbox: byRole('checkbox', { name: MetricKey.maintainability_issues }), + maintainabilityIssuesCheckbox: byRole('checkbox', { + name: MetricKey.software_quality_maintainability_issues, + }), newBugsCheckbox: byRole('checkbox', { name: MetricKey.new_bugs }), burnedBudgetCheckbox: byRole('checkbox', { name: MetricKey.burned_budget }), hiddenOptionsAlert: byText('project_activity.graphs.custom.type_x_message', { @@ -284,9 +286,9 @@ function renderActivityGraph( MetricKey.bugs, MetricKey.code_smells, MetricKey.vulnerabilities, - MetricKey.maintainability_issues, - MetricKey.reliability_issues, - MetricKey.security_issues, + MetricKey.software_quality_maintainability_issues, + MetricKey.software_quality_reliability_issues, + MetricKey.software_quality_security_issues, MetricKey.blocker_violations, MetricKey.lines_to_cover, MetricKey.uncovered_lines, diff --git a/server/sonar-web/src/main/js/components/activity-graph/utils.ts b/server/sonar-web/src/main/js/components/activity-graph/utils.ts index 9b6562d018b..06ef722bd9e 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/utils.ts +++ b/server/sonar-web/src/main/js/components/activity-graph/utils.ts @@ -167,11 +167,8 @@ export function generateSeries( ); return { data: measure.history.map((analysis) => { - let { value } = analysis; + const { value } = analysis; - if (value !== undefined && isSoftwareQualityMetric) { - value = JSON.parse(value).total; - } return { x: analysis.date, y: metric?.type === MetricType.Level ? value : Number(value), diff --git a/server/sonar-web/src/main/js/helpers/constants.ts b/server/sonar-web/src/main/js/helpers/constants.ts index 2afd6152403..aa702fc32e7 100644 --- a/server/sonar-web/src/main/js/helpers/constants.ts +++ b/server/sonar-web/src/main/js/helpers/constants.ts @@ -87,15 +87,15 @@ export const ISSUE_TYPES: IssueType[] = [ ]; export const CCT_SOFTWARE_QUALITY_METRICS = [ - MetricKey.security_issues, - MetricKey.reliability_issues, - MetricKey.maintainability_issues, + MetricKey.software_quality_security_issues, + MetricKey.software_quality_reliability_issues, + MetricKey.software_quality_maintainability_issues, ]; export const LEAK_CCT_SOFTWARE_QUALITY_METRICS = [ - MetricKey.new_security_issues, - MetricKey.new_reliability_issues, - MetricKey.new_maintainability_issues, + MetricKey.new_software_quality_security_issues, + MetricKey.new_software_quality_reliability_issues, + MetricKey.new_software_quality_maintainability_issues, ]; export const OLD_TAXONOMY_METRICS = [ @@ -132,9 +132,18 @@ export const LEAK_OLD_TAXONOMY_RATINGS = [ ]; export const OLD_TO_NEW_TAXONOMY_METRICS_MAP: { [key in MetricKey]?: MetricKey } = { - [MetricKey.vulnerabilities]: MetricKey.security_issues, - [MetricKey.bugs]: MetricKey.reliability_issues, - [MetricKey.code_smells]: MetricKey.maintainability_issues, + [MetricKey.vulnerabilities]: MetricKey.software_quality_security_issues, + [MetricKey.bugs]: MetricKey.software_quality_reliability_issues, + [MetricKey.code_smells]: MetricKey.software_quality_maintainability_issues, +}; + +export const SOFTWARE_QUALITIES_ISSUES_KEYS_MAP: Record<string, MetricKey> = { + [MetricKey.maintainability_issues]: MetricKey.software_quality_maintainability_issues, + [MetricKey.new_maintainability_issues]: MetricKey.new_software_quality_maintainability_issues, + [MetricKey.reliability_issues]: MetricKey.software_quality_reliability_issues, + [MetricKey.new_reliability_issues]: MetricKey.new_software_quality_reliability_issues, + [MetricKey.security_issues]: MetricKey.software_quality_security_issues, + [MetricKey.new_security_issues]: MetricKey.new_software_quality_security_issues, }; export const RESOLUTIONS = [ diff --git a/server/sonar-web/src/main/js/helpers/issues.ts b/server/sonar-web/src/main/js/helpers/issues.ts index 6f55df61794..2964d45b7f9 100644 --- a/server/sonar-web/src/main/js/helpers/issues.ts +++ b/server/sonar-web/src/main/js/helpers/issues.ts @@ -177,19 +177,19 @@ export function getIssueTypeBySoftwareQuality(quality: SoftwareQuality): IssueTy export const SOFTWARE_QUALITIES_METRIC_KEYS_MAP = { [SoftwareQuality.Security]: { - metric: MetricKey.security_issues, + metric: MetricKey.software_quality_security_issues, deprecatedMetric: MetricKey.vulnerabilities, rating: MetricKey.security_rating, newRating: MetricKey.new_security_rating, }, [SoftwareQuality.Reliability]: { - metric: MetricKey.reliability_issues, + metric: MetricKey.software_quality_reliability_issues, deprecatedMetric: MetricKey.bugs, rating: MetricKey.reliability_rating, newRating: MetricKey.new_reliability_rating, }, [SoftwareQuality.Maintainability]: { - metric: MetricKey.maintainability_issues, + metric: MetricKey.software_quality_maintainability_issues, deprecatedMetric: MetricKey.code_smells, rating: MetricKey.sqale_rating, newRating: MetricKey.new_maintainability_rating, diff --git a/server/sonar-web/src/main/js/helpers/measures.ts b/server/sonar-web/src/main/js/helpers/measures.ts index 90044e80d15..364ee85d42c 100644 --- a/server/sonar-web/src/main/js/helpers/measures.ts +++ b/server/sonar-web/src/main/js/helpers/measures.ts @@ -79,10 +79,7 @@ export function getDisplayMetrics(metrics: Metric[]) { return metrics.filter( (metric) => !metric.hidden && - ([...CCT_SOFTWARE_QUALITY_METRICS, ...LEAK_CCT_SOFTWARE_QUALITY_METRICS].includes( - metric.key as MetricKey, - ) || - ![MetricType.Data, MetricType.Distribution].includes(metric.type as MetricType)), + ![MetricType.Data, MetricType.Distribution].includes(metric.type as MetricType), ); } @@ -150,18 +147,6 @@ function isMeasureEnhanced(measure: Measure | MeasureEnhanced): measure is Measu return (measure.metric as Metric)?.key !== undefined; } -export const getCCTMeasureValue = (key: string, value?: string) => { - if ( - CCT_SOFTWARE_QUALITY_METRICS.concat(LEAK_CCT_SOFTWARE_QUALITY_METRICS).includes( - key as MetricKey, - ) && - value !== undefined - ) { - return JSON.parse(value).total; - } - return value; -}; - type RatingValue = 'A' | 'B' | 'C' | 'D' | 'E'; const RATING_VALUES: RatingValue[] = ['A', 'B', 'C', 'D', 'E']; export function formatRating(value: string | number | undefined): RatingValue | undefined { diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 1ebd3ff29b2..7422fcb52d4 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3742,10 +3742,13 @@ metric.new_software_quality_medium_issues.name=New Medium Severity Issues metric.new_software_quality_low_issues.description=New Low Severity issues metric.new_software_quality_low_issues.name=New Low Severity Issues metric.software_quality_maintainability_issues.name=Maintainability Issues +metric.software_quality_maintainability_issues.short_name=Maintainability metric.software_quality_maintainability_issues.description=Maintainability issues metric.software_quality_reliability_issues.name=Reliability Issues +metric.software_quality_reliability_issues.short_name=Reliability metric.software_quality_reliability_issues.description=Reliability issues metric.software_quality_security_issues.name=Security Issues +metric.software_quality_security_issues.short_name=Security metric.software_quality_security_issues.description=Security issues metric.new_software_quality_maintainability_issues.name=New Maintainability Issues metric.new_software_quality_maintainability_issues.description=New maintainability issues @@ -4666,13 +4669,19 @@ component_measures.not_all_measures_are_shown=Not all projects and applications component_measures.not_all_measures_are_shown.help=You do not have access to all projects and/or applications. Measures are still computed based on all projects and applications. component_measures.metric.new_security_issues.name=Issues +component_measures.metric.new_software_quality_security_issues.name=Issues component_measures.metric.new_security_issues.detailed_name=New Issues +component_measures.metric.new_software_quality_security_issues.detailed_name=New Issues component_measures.metric.new_vulnerabilities.name=Vulnerabilities component_measures.metric.new_vulnerabilities.detailed_name=New Vulnerabilities component_measures.metric.new_reliability_issues.name=Issues +component_measures.metric.new_software_quality_reliability_issues.name=Issues component_measures.metric.new_reliability_issues.detailed_name=New Issues +component_measures.metric.new_software_quality_reliability_issues.detailed_name=New Issues component_measures.metric.new_maintainability_issues.name=Issues +component_measures.metric.new_software_quality_maintainability_issues.name=Issues component_measures.metric.new_maintainability_issues.detailed_name=New Issues +component_measures.metric.new_software_quality_maintainability_issues.detailed_name=New Issues component_measures.metric.new_code_smells.name=Code Smells component_measures.metric.new_code_smells.detailed_name=New Code Smells component_measures.metric.new_violations.name=Open Issues @@ -4682,10 +4691,13 @@ component_measures.metric.new_accepted_issues.detailed_name=New Accepted Issues component_measures.metric.new_bugs.name=Bugs component_measures.metric.new_bugs.detailed_name=New Bugs component_measures.metric.security_issues.name=Issues +component_measures.metric.software_quality_security_issues.name=Issues component_measures.metric.vulnerabilities.name=Vulnerabilities component_measures.metric.reliability_issues.name=Issues +component_measures.metric.software_quality_reliability_issues.name=Issues component_measures.metric.bugs.name=Bugs component_measures.metric.maintainability_issues.name=Issues +component_measures.metric.software_quality_maintainability_issues.name=Issues component_measures.metric.code_smells.name=Code Smells component_measures.metric.violations.name=Open Issues component_measures.metric.accepted_issues.name=Accepted Issues |