From 56814730f18b0c7257a8f002d098d452920f1632 Mon Sep 17 00:00:00 2001 From: stanislavh Date: Wed, 3 Jul 2024 13:45:12 +0200 Subject: [PATCH] SONAR-21895 Use violations metric to show the difference in analysis --- .../overview/branches/AnalysisVariations.tsx | 3 +- .../branches/__tests__/ActivityPanel-it.tsx | 36 +++++-------------- .../src/main/js/apps/overview/utils.tsx | 4 +-- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/overview/branches/AnalysisVariations.tsx b/server/sonar-web/src/main/js/apps/overview/branches/AnalysisVariations.tsx index 728f59ee6e1..afcd4b455a9 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/AnalysisVariations.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/AnalysisVariations.tsx @@ -89,8 +89,7 @@ function Variation(props: Readonly) { export function AnalysisVariations(props: Readonly) { const { isFirstAnalysis, variations } = props; - const issuesVariation = - (variations.bugs ?? 0) + (variations.code_smells ?? 0) + (variations.vulnerabilities ?? 0); + const issuesVariation = variations.violations ?? 0; const coverageVariation = variations.coverage; const duplicationsVariation = variations.duplicated_lines_density; diff --git a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx index abbf0824c96..eaa0ed1feaa 100644 --- a/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx +++ b/server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx @@ -55,17 +55,17 @@ it('should render correctly', async () => { expect(screen.getAllByText(/project_activity\.graphs\.coverage$/)).toHaveLength(3); expect(screen.getAllByText(/project_activity\.graphs\.duplications$/)).toHaveLength(3); // Analysis 1 (latest) - expect(screen.getByText(/^\+0 project_activity\.graphs\.issues$/)).toBeInTheDocument(); + expect(screen.getByText(/^-5 project_activity\.graphs\.issues$/)).toBeInTheDocument(); expect(screen.getByText(/^\+6\.5% project_activity\.graphs\.duplications$/)).toBeInTheDocument(); // Analysis 2 - expect(screen.getByText(/^\+2 project_activity\.graphs\.issues$/)).toBeInTheDocument(); + expect(screen.getByText(/^-100 project_activity\.graphs\.issues$/)).toBeInTheDocument(); expect(screen.getByText(/^-1\.0% project_activity\.graphs\.coverage$/)).toBeInTheDocument(); // Analysis 3 - expect(screen.getByText(/^-100 project_activity\.graphs\.issues$/)).toBeInTheDocument(); + expect(screen.getByText(/^\+0 project_activity\.graphs\.issues$/)).toBeInTheDocument(); expect(screen.getByText(/^\+15\.2% project_activity\.graphs\.coverage$/)).toBeInTheDocument(); expect(screen.getByText(/^-1\.5% project_activity\.graphs\.duplications$/)).toBeInTheDocument(); // Analysis 4 (first one) - expect(screen.getByText(/^502 project_activity\.graphs\.issues$/)).toBeInTheDocument(); + expect(screen.getByText(/^200 project_activity\.graphs\.issues$/)).toBeInTheDocument(); expect(screen.getByText(/^0\.0% project_activity\.graphs\.coverage$/)).toBeInTheDocument(); expect(screen.getByText(/^10\.0% project_activity\.graphs\.duplications$/)).toBeInTheDocument(); @@ -86,30 +86,12 @@ it('should render correctly', async () => { function renderActivityPanel() { const mockedMeasureHistory = [ mockMeasureHistory({ - metric: MetricKey.code_smells, - history: [ - mockHistoryItem({ date: parseDate('2018-10-27T10:21:15+0200'), value: '500' }), - mockHistoryItem({ date: parseDate('2018-10-27T12:21:15+0200'), value: '400' }), - mockHistoryItem({ date: parseDate('2020-10-27T16:33:50+0200'), value: '400' }), - mockHistoryItem({ date: parseDate('2020-10-27T18:33:50+0200'), value: '400' }), - ], - }), - mockMeasureHistory({ - metric: MetricKey.bugs, - history: [ - mockHistoryItem({ date: parseDate('2018-10-27T10:21:15+0200'), value: '0' }), - mockHistoryItem({ date: parseDate('2018-10-27T12:21:15+0200'), value: '0' }), - mockHistoryItem({ date: parseDate('2020-10-27T16:33:50+0200'), value: '2' }), - mockHistoryItem({ date: parseDate('2020-10-27T18:33:50+0200'), value: '0' }), - ], - }), - mockMeasureHistory({ - metric: MetricKey.vulnerabilities, + metric: MetricKey.violations, history: [ - mockHistoryItem({ date: parseDate('2018-10-27T10:21:15+0200'), value: '2' }), - mockHistoryItem({ date: parseDate('2018-10-27T12:21:15+0200'), value: '2' }), - mockHistoryItem({ date: parseDate('2020-10-27T16:33:50+0200'), value: '2' }), - mockHistoryItem({ date: parseDate('2020-10-27T18:33:50+0200'), value: '4' }), + mockHistoryItem({ date: parseDate('2018-10-27T10:21:15+0200'), value: '200' }), + mockHistoryItem({ date: parseDate('2018-10-27T12:21:15+0200'), value: '200' }), + mockHistoryItem({ date: parseDate('2020-10-27T16:33:50+0200'), value: '100' }), + mockHistoryItem({ date: parseDate('2020-10-27T18:33:50+0200'), value: '95' }), ], }), mockMeasureHistory({ 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 34ed343f960..b2446f0dd89 100644 --- a/server/sonar-web/src/main/js/apps/overview/utils.tsx +++ b/server/sonar-web/src/main/js/apps/overview/utils.tsx @@ -125,11 +125,9 @@ export const HISTORY_METRICS_LIST: string[] = [ ]; const MEASURES_VARIATIONS_METRICS = [ - MetricKey.bugs, - MetricKey.code_smells, MetricKey.coverage, MetricKey.duplicated_lines_density, - MetricKey.vulnerabilities, + MetricKey.violations, ]; export enum MeasurementType { -- 2.39.5