];
export const HISTORY_METRICS_LIST: string[] = [
- MetricKey.bugs,
- MetricKey.vulnerabilities,
- MetricKey.sqale_index,
+ MetricKey.violations,
MetricKey.duplicated_lines_density,
MetricKey.ncloc,
MetricKey.coverage,
timeMachineHandler.setMeasureHistory(
[
+ MetricKey.violations,
MetricKey.bugs,
MetricKey.reliability_rating,
MetricKey.code_smells,
renderProjectActivityAppContainer();
await ui.appLoaded();
- expect(ui.bugsPopupCell.query()).not.toBeInTheDocument();
+ expect(ui.issuesPopupCell.query()).not.toBeInTheDocument();
await ui.showDetails('1.1.0.1');
- expect(ui.bugsPopupCell.get()).toBeInTheDocument();
+ expect(ui.issuesPopupCell.get()).toBeInTheDocument();
});
it('should correctly handle customizing the graph', async () => {
// Misc.
loading: byText('loading'),
baseline: byText('project_activity.new_code_period_start'),
- bugsPopupCell: byRole('cell', { name: MetricKey.bugs }),
+ issuesPopupCell: byRole('cell', { name: `metric.${MetricKey.violations}.name` }),
monthSelector: byTestId('month-select'),
yearSelector: byTestId('year-select'),
};
import GraphsTooltipsContentCoverage from './GraphsTooltipsContentCoverage';
import GraphsTooltipsContentDuplication from './GraphsTooltipsContentDuplication';
import GraphsTooltipsContentEvents from './GraphsTooltipsContentEvents';
-import GraphsTooltipsContentIssues from './GraphsTooltipsContentIssues';
-import { DEFAULT_GRAPH } from './utils';
interface PropsWithoutTheme {
events: AnalysisEvent[];
export class GraphsTooltipsClass extends React.PureComponent<Props> {
renderContent() {
- const { tooltipIdx, series, graph, measuresHistory } = this.props;
+ const { tooltipIdx, series } = this.props;
return series.map((serie, idx) => {
const point = serie.data[tooltipIdx];
return null;
}
- if (graph === DEFAULT_GRAPH) {
- return (
- <GraphsTooltipsContentIssues
- index={idx}
- key={serie.name}
- measuresHistory={measuresHistory}
- name={serie.name}
- tooltipIdx={tooltipIdx}
- translatedName={serie.translatedName}
- value={this.props.formatValue(point.y)}
- />
- );
- }
-
return (
<GraphsTooltipsContent
index={idx}
+++ /dev/null
-/*
- * 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.
- */
-import { MetricsEnum, MetricsRatingBadge } from 'design-system';
-import * as React from 'react';
-import { ChartLegendIcon } from '../../components/icons/ChartLegendIcon';
-import { MetricKey } from '../../types/metrics';
-import { MeasureHistory } from '../../types/project-activity';
-import { Dict } from '../../types/types';
-
-export interface GraphsTooltipsContentIssuesProps {
- index: number;
- measuresHistory: MeasureHistory[];
- name: string;
- tooltipIdx: number;
- translatedName: string;
- value: string;
-}
-
-const METRIC_RATING: Dict<string> = {
- [MetricKey.bugs]: MetricKey.reliability_rating,
- [MetricKey.vulnerabilities]: MetricKey.security_rating,
- [MetricKey.code_smells]: MetricKey.sqale_rating,
-};
-
-export default function GraphsTooltipsContentIssues(props: GraphsTooltipsContentIssuesProps) {
- const { index, measuresHistory, name, tooltipIdx, translatedName, value } = props;
- const rating = measuresHistory.find((measure) => measure.metric === METRIC_RATING[name]);
-
- if (!rating?.history[tooltipIdx]) {
- return null;
- }
-
- const ratingValue = rating.history[tooltipIdx].value;
-
- const ratingEnumValue =
- (ratingValue &&
- {
- '1.0': MetricsEnum.A,
- '2.0': MetricsEnum.B,
- '3.0': MetricsEnum.C,
- '4.0': MetricsEnum.D,
- '5.0': MetricsEnum.E,
- }[ratingValue]) ||
- undefined;
-
- return (
- <tr className="sw-h-8" key={name}>
- <td className="sw-w-5">
- <ChartLegendIcon className="sw-mr-0" index={index} />
- </td>
- <td>
- <span className="sw-body-sm-highlight sw-ml-2">{value}</span>
- </td>
- <td>
- <span className="sw-body-sm">{translatedName}</span>
- </td>
- {ratingValue && (
- <td>
- <MetricsRatingBadge label={ratingValue} rating={ratingEnumValue} size="xs" />
- </td>
- )}
- </tr>
- );
-}
renderActivityGraph();
// Static legend items, which aren't interactive.
- expect(ui.legendRemoveMetricBtn(MetricKey.bugs).query()).not.toBeInTheDocument();
- expect(ui.getLegendItem(MetricKey.bugs)).toBeInTheDocument();
+ expect(ui.legendRemoveMetricBtn(MetricKey.violations).query()).not.toBeInTheDocument();
+ expect(ui.getLegendItem(MetricKey.violations)).toBeInTheDocument();
// Switch to custom graph.
await ui.changeGraphType(GraphType.custom);
await ui.openDataTable();
expect(ui.dataTable.get()).toBeInTheDocument();
- expect(ui.dataTableColHeaders.getAll()).toHaveLength(5);
+ expect(ui.dataTableColHeaders.getAll()).toHaveLength(3);
expect(ui.dataTableRows.getAll()).toHaveLength(HISTORY_COUNT + 1);
// Change graph type and dates, check table updates correctly.
await ui.openDataTable();
expect(ui.dataTable.get()).toBeInTheDocument();
- expect(ui.dataTableColHeaders.getAll()).toHaveLength(5);
+ expect(ui.dataTableColHeaders.getAll()).toHaveLength(3);
expect(ui.dataTableRows.getAll()).toHaveLength(2);
});
});
const measuresHistory: MeasureHistory[] = [];
const metrics: Metric[] = [];
[
+ MetricKey.violations,
MetricKey.bugs,
MetricKey.code_smells,
MetricKey.confirmed_issues,
function mockSeries(n = 10) {
const measuresHistory: MeasureHistory[] = [];
const metrics: Metric[] = [];
- [MetricKey.bugs, MetricKey.code_smells, MetricKey.vulnerabilities].forEach((metric) => {
+ [MetricKey.violations].forEach((metric) => {
const history = times(n, (i) => {
const date = parseDate('2016-01-01T00:00:00+0200');
date.setDate(date.getDate() + 365 * i);
import { generateSeries, getDisplayedHistoryMetrics } from '../utils';
it.each([
- [
- GraphType.issues,
- [
- [MetricKey.bugs, 1, 3],
- [MetricKey.code_smells, 0, 1],
- [MetricKey.vulnerabilities, 2, 5],
- ],
- ],
+ [GraphType.issues, [[MetricKey.violations, 1]]],
[
GraphType.coverage,
[
(
[
+ [MetricKey.violations, '1'],
[MetricKey.bugs, '1'],
- [MetricKey.reliability_rating, '3'],
- [MetricKey.code_smells, '0'],
- [MetricKey.sqale_rating, '1'],
- [MetricKey.vulnerabilities, '2'],
- [MetricKey.security_rating, '5'],
[MetricKey.lines_to_cover, '10'],
[MetricKey.uncovered_lines, '8'],
[MetricKey.coverage, '75'],
const customMetrics = ['foo', 'bar'];
it('should return only displayed metrics on the graph', () => {
expect(utils.getDisplayedHistoryMetrics(utils.DEFAULT_GRAPH, [])).toEqual([
- MetricKey.bugs,
- MetricKey.code_smells,
- MetricKey.vulnerabilities,
+ MetricKey.violations,
]);
expect(utils.getDisplayedHistoryMetrics(GraphType.coverage, customMetrics)).toEqual([
MetricKey.lines_to_cover,
const customMetrics = ['foo', 'bar'];
it('should return all metrics', () => {
expect(utils.getHistoryMetrics(utils.DEFAULT_GRAPH, [])).toEqual([
- MetricKey.bugs,
- MetricKey.code_smells,
- MetricKey.vulnerabilities,
+ MetricKey.violations,
MetricKey.reliability_rating,
MetricKey.security_rating,
MetricKey.sqale_rating,
export const DEFAULT_GRAPH = GraphType.issues;
const GRAPHS_METRICS_DISPLAYED: Dict<string[]> = {
- [GraphType.issues]: [MetricKey.bugs, MetricKey.code_smells, MetricKey.vulnerabilities],
+ [GraphType.issues]: [MetricKey.violations],
[GraphType.coverage]: [MetricKey.lines_to_cover, MetricKey.uncovered_lines],
[GraphType.duplications]: [MetricKey.ncloc, MetricKey.duplicated_lines],
};