]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21895 Use violations metric to show the difference in analysis
authorstanislavh <stanislav.honcharov@sonarsource.com>
Wed, 3 Jul 2024 11:45:12 +0000 (13:45 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 3 Jul 2024 20:02:43 +0000 (20:02 +0000)
server/sonar-web/src/main/js/apps/overview/branches/AnalysisVariations.tsx
server/sonar-web/src/main/js/apps/overview/branches/__tests__/ActivityPanel-it.tsx
server/sonar-web/src/main/js/apps/overview/utils.tsx

index 728f59ee6e17929142deaa80e20b1cf56791ad2a..afcd4b455a9053a46603418029a2e440d87621dd 100644 (file)
@@ -89,8 +89,7 @@ function Variation(props: Readonly<VariationProps>) {
 export function AnalysisVariations(props: Readonly<AnalysisVariationsProps>) {
   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;
 
index abbf0824c967030722ca720be2b274ef24f3a226..eaa0ed1feaa80a29c10318b779f19c6f068437c2 100644 (file)
@@ -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({
index 34ed343f9609937cb1bb95bd2fe96463d0ce83a3..b2446f0dd89fe81b8df1132b88c7eea0416c20e4 100644 (file)
@@ -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 {