diff options
author | Philippe Perrin <philippe.perrin@sonarsource.com> | 2022-11-02 11:08:39 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-11-02 20:03:01 +0000 |
commit | 2ab6fc273ecbf405f7c126fab11ddc0b9bf516da (patch) | |
tree | a6e005b4f57fb488d3e551b7df52399e69b0674c /server/sonar-web/src/main/js/components/activity-graph | |
parent | 60e4b88e4567c1af3051b6cdc4c8858f8b0fca21 (diff) | |
download | sonarqube-2ab6fc273ecbf405f7c126fab11ddc0b9bf516da.tar.gz sonarqube-2ab6fc273ecbf405f7c126fab11ddc0b9bf516da.zip |
SONAR-13368 Bump to prettier@2.7.1
Diffstat (limited to 'server/sonar-web/src/main/js/components/activity-graph')
29 files changed, 182 insertions, 173 deletions
diff --git a/server/sonar-web/src/main/js/components/activity-graph/AddGraphMetric.tsx b/server/sonar-web/src/main/js/components/activity-graph/AddGraphMetric.tsx index 29dfd8d6fb8..0d43caa4f56 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/AddGraphMetric.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/AddGraphMetric.tsx @@ -45,14 +45,12 @@ export default class AddGraphMetric extends React.PureComponent<Props, State> { state: State = { metrics: [], query: '', - selectedMetrics: [] + selectedMetrics: [], }; filterSelected = (query: string, selectedElements: string[]) => { - return selectedElements.filter(element => - this.getLocalizedMetricNameFromKey(element) - .toLowerCase() - .includes(query.toLowerCase()) + return selectedElements.filter((element) => + this.getLocalizedMetricNameFromKey(element).toLowerCase().includes(query.toLowerCase()) ); }; @@ -61,15 +59,13 @@ export default class AddGraphMetric extends React.PureComponent<Props, State> { query: string ) => { return metrics - .filter(metric => { + .filter((metric) => { if ( metric.hidden || isDiffMetric(metric.key) || ['DATA', 'DISTRIB'].includes(metric.type) || selectedMetrics.includes(metric.key) || - !getLocalizedMetricName(metric) - .toLowerCase() - .includes(query.toLowerCase()) + !getLocalizedMetricName(metric).toLowerCase().includes(query.toLowerCase()) ) { return false; } @@ -78,12 +74,12 @@ export default class AddGraphMetric extends React.PureComponent<Props, State> { } return true; }) - .map(metric => metric.key); + .map((metric) => metric.key); }; getSelectedMetricsElements = (metrics: Metric[], selectedMetrics?: string[]) => { const selected = selectedMetrics || this.props.selectedMetrics; - return metrics.filter(metric => selected.includes(metric.key)).map(metric => metric.key); + return metrics.filter((metric) => selected.includes(metric.key)).map((metric) => metric.key); }; getLocalizedMetricNameFromKey = (key: string) => { @@ -98,20 +94,20 @@ export default class AddGraphMetric extends React.PureComponent<Props, State> { onSelect = (metric: string) => { this.props.addMetric(metric); - this.setState(state => { + this.setState((state) => { return { selectedMetrics: sortBy([...state.selectedMetrics, metric]), - metrics: this.filterMetricsElements(this.props, state.query) + metrics: this.filterMetricsElements(this.props, state.query), }; }); }; onUnselect = (metric: string) => { this.props.removeMetric(metric); - this.setState(state => { + this.setState((state) => { return { metrics: sortBy([...state.metrics, metric]), - selectedMetrics: state.selectedMetrics.filter(selected => selected !== metric) + selectedMetrics: state.selectedMetrics.filter((selected) => selected !== metric), }; }); }; @@ -136,10 +132,11 @@ export default class AddGraphMetric extends React.PureComponent<Props, State> { onSearch={this.onSearch} onSelect={this.onSelect} onUnselect={this.onUnselect} - renderLabel={element => this.getLocalizedMetricNameFromKey(element)} + renderLabel={(element) => this.getLocalizedMetricNameFromKey(element)} selectedElements={selectedMetrics} /> - }> + } + > <Button className="spacer-left"> <span className="text-ellipsis text-middle"> {translate('project_activity.graphs.custom.add')} diff --git a/server/sonar-web/src/main/js/components/activity-graph/DataTableModal.tsx b/server/sonar-web/src/main/js/components/activity-graph/DataTableModal.tsx index ef88cf83586..0b0fabb17e4 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/DataTableModal.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/DataTableModal.tsx @@ -99,14 +99,14 @@ export default function DataTableModal(props: DataTableModalProps) { <TimeFormatter date={date} /> </div> </td> - {metrics.map(metric => ( + {metrics.map((metric) => ( <td key={metric} className="thin nowrap"> {values[metric] || '-'} </td> ))} <td> <ul> - {getAnalysisEventsForDate(analyses, date).map(event => ( + {getAnalysisEventsForDate(analyses, date).map((event) => ( <li className="little-spacer-bottom" key={event.key}> <EventInner event={event} readonly={true} /> </li> @@ -158,7 +158,7 @@ export default function DataTableModal(props: DataTableModalProps) { <thead> <tr> <th>{translate('date')}</th> - {series.map(serie => ( + {series.map((serie) => ( <th key={serie.name} className="thin nowrap"> {serie.translatedName} </th> diff --git a/server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx b/server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx index 7d52c9c970b..41ea7117793 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/DefinitionChangeEventInner.tsx @@ -55,14 +55,15 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State }; toggleProjectsList = () => { - this.setState(state => ({ expanded: !state.expanded })); + this.setState((state) => ({ expanded: !state.expanded })); }; renderProjectLink = (project: { key: string; name: string }, branch: string | undefined) => ( <Link onClick={this.stopPropagation} title={project.name} - to={getProjectUrl(project.key, branch)}> + to={getProjectUrl(project.key, branch)} + > {limitComponentName(project.name, 28)} </Link> ); @@ -95,7 +96,7 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State id={message} values={{ project: this.renderProjectLink(project, project.branch), - branch: this.renderBranch(project.branch) + branch: this.renderBranch(project.branch), }} /> </div> @@ -111,7 +112,7 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State id={message} values={{ project: this.renderProjectLink(project, project.branch), - branch: this.renderBranch(project.branch) + branch: this.renderBranch(project.branch), }} /> </div> @@ -124,7 +125,7 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State values={{ project: this.renderProjectLink(project, project.newBranch), oldBranch: this.renderBranch(project.oldBranch), - newBranch: this.renderBranch(project.newBranch) + newBranch: this.renderBranch(project.newBranch), }} /> ); @@ -147,7 +148,8 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State <ButtonLink className="project-activity-event-inner-more-link" onClick={this.toggleProjectsList} - stopPropagation={true}> + stopPropagation={true} + > {expanded ? translate('hide') : translate('more')} <DropdownIcon className="little-spacer-left" turned={expanded} /> </ButtonLink> @@ -156,7 +158,7 @@ export class DefinitionChangeEventInner extends React.PureComponent<Props, State {expanded && ( <ul className="spacer-left spacer-top"> - {event.definitionChange.projects.map(project => ( + {event.definitionChange.projects.map((project) => ( <li className="display-flex-center spacer-top" key={project.key}> {this.renderProjectChange(project)} </li> diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx index bb674ec3a21..6698d2b614d 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphHistory.tsx @@ -86,7 +86,7 @@ export default class GraphHistory extends React.PureComponent<Props, State> { selectedDate, series, showAreas, - graphDescription + graphDescription, } = this.props; const { tooltipIdx, tooltipXPos } = this.state; const events = getAnalysisEventsForDate(analyses, selectedDate); @@ -149,7 +149,8 @@ export default class GraphHistory extends React.PureComponent<Props, State> { series={series} onClose={onClose} /> - )}> + )} + > {({ onClick }) => ( <Button className="a11y-hidden" onClick={onClick}> {translate('project_activity.graphs.open_in_table')} diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsHeader.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsHeader.tsx index c15aaac724a..1dd1d58ae4f 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsHeader.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsHeader.tsx @@ -53,14 +53,14 @@ export default class GraphsHeader extends React.PureComponent<Props> { metrics, metricsTypeFilter, removeCustomMetric, - selectedMetrics = [] + selectedMetrics = [], } = this.props; const types = getGraphTypes(addCustomMetric === undefined || removeCustomMetric === undefined); - const selectOptions = types.map(type => ({ + const selectOptions = types.map((type) => ({ label: translate('project_activity.graphs', type), - value: type + value: type, })); return ( @@ -76,7 +76,7 @@ export default class GraphsHeader extends React.PureComponent<Props> { isSearchable={false} onChange={this.handleGraphChange} options={selectOptions} - value={selectOptions.find(option => option.value === graph)} + value={selectOptions.find((option) => option.value === graph)} /> </div> {isCustomGraph(graph) && diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsHistory.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsHistory.tsx index d4924ebb2be..0f4f8436644 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsHistory.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsHistory.tsx @@ -53,7 +53,7 @@ export default class GraphsHistory extends React.PureComponent<Props, State> { constructor(props: Props) { super(props); this.state = { - selectedDate: props.selectedDate + selectedDate: props.selectedDate, }; } diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendCustom.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendCustom.tsx index 6dba9551e5e..a8f54da826a 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendCustom.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendCustom.tsx @@ -49,7 +49,8 @@ export default function GraphsLegendCustom(props: GraphsLegendCustomProps) { return ( <Tooltip key={serie.name} - overlay={translate('project_activity.graphs.custom.metric_no_history')}> + overlay={translate('project_activity.graphs.custom.metric_no_history')} + > <span className="spacer-left spacer-right">{legendItem}</span> </Tooltip> ); diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendNewCode.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendNewCode.tsx index 928c315a15f..06e81da93e4 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendNewCode.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsLegendNewCode.tsx @@ -26,7 +26,8 @@ export default function GraphsLegendNewCode() { <Tooltip overlay={translate('project_activity.graphs.new_code_long')}> <span aria-label={translate('project_activity.graphs.new_code_long')} - className="activity-graph-new-code-legend display-flex-center pull-right note"> + className="activity-graph-new-code-legend display-flex-center pull-right note" + > {translate('project_activity.graphs.new_code')} </span> </Tooltip> diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltips.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltips.tsx index b7d49b60cd5..9950dc79b32 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltips.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltips.tsx @@ -93,7 +93,8 @@ export default class GraphsTooltips extends React.PureComponent<Props> { <Popup className="disabled-pointer-events" placement={placement} - style={{ top, left, width: TOOLTIP_WIDTH }}> + style={{ top, left, width: TOOLTIP_WIDTH }} + > <div className="activity-graph-tooltip"> <div className="activity-graph-tooltip-title spacer-bottom"> <DateTimeFormatter date={this.props.selectedDate} /> diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentCoverage.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentCoverage.tsx index edfc58c2e83..6021f6e382c 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentCoverage.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentCoverage.tsx @@ -31,10 +31,10 @@ export interface GraphsTooltipsContentCoverageProps { export default function GraphsTooltipsContentCoverage({ addSeparator, measuresHistory, - tooltipIdx + tooltipIdx, }: GraphsTooltipsContentCoverageProps) { - const uncovered = measuresHistory.find(measure => measure.metric === 'uncovered_lines'); - const coverage = measuresHistory.find(measure => measure.metric === 'coverage'); + const uncovered = measuresHistory.find((measure) => measure.metric === 'uncovered_lines'); + const coverage = measuresHistory.find((measure) => measure.metric === 'coverage'); if (!uncovered || !uncovered.history[tooltipIdx] || !coverage || !coverage.history[tooltipIdx]) { return null; } diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentDuplication.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentDuplication.tsx index 5c4a66aa2cf..e97d87d4f09 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentDuplication.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentDuplication.tsx @@ -31,10 +31,10 @@ export interface GraphsTooltipsContentDuplicationProps { export default function GraphsTooltipsContentDuplication({ addSeparator, measuresHistory, - tooltipIdx + tooltipIdx, }: GraphsTooltipsContentDuplicationProps) { const duplicationDensity = measuresHistory.find( - measure => measure.metric === 'duplicated_lines_density' + (measure) => measure.metric === 'duplicated_lines_density' ); if (!duplicationDensity || !duplicationDensity.history[tooltipIdx]) { return null; diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentEvents.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentEvents.tsx index 85cafa0761b..ceba6c071c4 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentEvents.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentEvents.tsx @@ -38,7 +38,7 @@ export default function GraphsTooltipsContentEvents({ addSeparator, events }: Pr )} <tr className="activity-graph-tooltip-line"> <td colSpan={3}> - {events.map(event => ( + {events.map((event) => ( <div className="little-spacer-bottom" key={event.key}> <EventInner event={event} readonly={true} /> </div> diff --git a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentIssues.tsx b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentIssues.tsx index f4a97626c52..3ca06bd94ba 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentIssues.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/GraphsTooltipsContentIssues.tsx @@ -35,12 +35,12 @@ export interface GraphsTooltipsContentIssuesProps { const METRIC_RATING: Dict<string> = { bugs: 'reliability_rating', vulnerabilities: 'security_rating', - code_smells: 'sqale_rating' + code_smells: 'sqale_rating', }; export default function GraphsTooltipsContentIssues(props: GraphsTooltipsContentIssuesProps) { const rating = props.measuresHistory.find( - measure => measure.metric === METRIC_RATING[props.name] + (measure) => measure.metric === METRIC_RATING[props.name] ); if (!rating || !rating.history[props.tooltipIdx]) { return null; diff --git a/server/sonar-web/src/main/js/components/activity-graph/RichQualityGateEventInner.tsx b/server/sonar-web/src/main/js/components/activity-graph/RichQualityGateEventInner.tsx index 2f81862002c..f89adab3749 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/RichQualityGateEventInner.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/RichQualityGateEventInner.tsx @@ -50,7 +50,7 @@ export class RichQualityGateEventInner extends React.PureComponent<Props, State> }; toggleProjectsList = () => { - this.setState(state => ({ expanded: !state.expanded })); + this.setState((state) => ({ expanded: !state.expanded })); }; render() { @@ -74,7 +74,8 @@ export class RichQualityGateEventInner extends React.PureComponent<Props, State> <ResetButtonLink className="project-activity-event-inner-more-link" onClick={this.toggleProjectsList} - stopPropagation={true}> + stopPropagation={true} + > {expanded ? translate('hide') : translate('more')} <DropdownIcon className="little-spacer-left" turned={expanded} /> </ResetButtonLink> @@ -83,7 +84,7 @@ export class RichQualityGateEventInner extends React.PureComponent<Props, State> {expanded && ( <ul className="spacer-left spacer-top"> - {event.qualityGate.failing.map(project => ( + {event.qualityGate.failing.map((project) => ( <li className="display-flex-center spacer-top" key={project.key}> <Level aria-label={translate('quality_gates.status')} @@ -95,7 +96,8 @@ export class RichQualityGateEventInner extends React.PureComponent<Props, State> <Link onClick={this.stopPropagation} title={project.name} - to={getProjectUrl(project.key, project.branch)}> + to={getProjectUrl(project.key, project.branch)} + > <span aria-label={translateWithParameters('project_x', project.name)}> {project.name} </span> 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 786e404631d..42d90877818 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 @@ -30,7 +30,7 @@ import { mockAnalysisEvent, mockHistoryItem, mockMeasureHistory, - mockParsedAnalysis + mockParsedAnalysis, } from '../../../helpers/mocks/project-activity'; import { mockMetric } from '../../../helpers/testMocks'; import { renderComponent } from '../../../helpers/testReactTestingUtils'; @@ -52,7 +52,7 @@ const ui = { burnedBudgetCheckbox: byRole('checkbox', { name: MetricKey.burned_budget }), vulnerabilityCheckbox: byRole('checkbox', { name: MetricKey.vulnerabilities }), hiddenOptionsAlert: byText('project_activity.graphs.custom.type_x_message', { - exact: false + exact: false, }), maxOptionsAlert: byText('project_activity.graphs.custom.add_metric_info'), filterMetrics: byPlaceholderText('search.search_for_metrics'), @@ -74,8 +74,8 @@ const ui = { dataTableColHeaders: byRole('columnheader'), onlyFirst100Text: byText('project_activity.graphs.data_table.max_lines_warning.100'), noDataTableText: byText('project_activity.graphs.data_table.no_data_warning_check_dates_x', { - exact: false - }) + exact: false, + }), }; it('should correctly handle adding/removing custom metrics', async () => { @@ -171,7 +171,7 @@ it('shows the same data in a table when filtered by date', async () => { const user = userEvent.setup(); renderActivityGraph({ graphStartDate: parseDate('2017-01-01'), - graphEndDate: parseDate('2019-01-01') + graphEndDate: parseDate('2019-01-01'), }); await user.click(ui.openInTableBtn.get()); @@ -230,9 +230,9 @@ function renderActivityGraph( MetricKey.uncovered_lines, MetricKey.coverage, MetricKey.duplicated_lines_density, - MetricKey.test_success_density - ].forEach(metric => { - const history = times(HISTORY_COUNT, i => { + MetricKey.test_success_density, + ].forEach((metric) => { + const history = times(HISTORY_COUNT, (i) => { const date = parseDate('2016-01-01T00:00:00+0200'); date.setDate(date.getDate() + i); return mockHistoryItem({ date, value: i.toString() }); @@ -246,7 +246,7 @@ function renderActivityGraph( mockMetric({ key: metric, name: metric, - type: metric.includes('_density') || metric === MetricKey.coverage ? 'PERCENT' : 'INT' + type: metric.includes('_density') || metric === MetricKey.coverage ? 'PERCENT' : 'INT', }) ); }); @@ -267,14 +267,16 @@ function renderActivityGraph( const metricsTypeFilter = graphs.length < MAX_GRAPHS ? undefined - : graphs.filter(graph => graph.length < MAX_SERIES_PER_GRAPH).map(graph => graph[0].type); + : graphs + .filter((graph) => graph.length < MAX_SERIES_PER_GRAPH) + .map((graph) => graph[0].type); const addCustomMetric = (metricKey: string) => { setSelectedMetrics([...selectedMetrics, metricKey]); }; const removeCustomMetric = (metricKey: string) => { - setSelectedMetrics(selectedMetrics.filter(m => m !== metricKey)); + setSelectedMetrics(selectedMetrics.filter((m) => m !== metricKey)); }; const updateGraph = (graphType: string) => { @@ -312,18 +314,18 @@ function renderActivityGraph( key: '2', category: 'VERSION', description: undefined, - qualityGate: undefined + qualityGate: undefined, }), mockAnalysisEvent({ key: '3', category: 'DEFINITION_CHANGE', definitionChange: { - projects: [{ changeType: 'ADDED', key: 'foo', name: 'Foo' }] + projects: [{ changeType: 'ADDED', key: 'foo', name: 'Foo' }], }, - qualityGate: undefined - }) - ] - }) + qualityGate: undefined, + }), + ], + }), ]} graph={graph} graphEndDate={toDate} diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/DataTableModal-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/DataTableModal-test.tsx index d9ec3fd7d1e..b4d16fb678e 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/DataTableModal-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/DataTableModal-test.tsx @@ -49,7 +49,7 @@ it('should render correctly if there is no data and we have a start date', () => renderDataTableModal({ graphStartDate: parseDate('3022-01-01') }); expect( screen.getByText('project_activity.graphs.data_table.no_data_warning_check_dates_x', { - exact: false + exact: false, }) ).toBeInTheDocument(); }); @@ -58,7 +58,7 @@ it('should render correctly if there is no data and we have an end date', () => renderDataTableModal({ graphEndDate: parseDate('2015-01-01') }); expect( screen.getByText('project_activity.graphs.data_table.no_data_warning_check_dates_y', { - exact: false + exact: false, }) ).toBeInTheDocument(); }); @@ -66,11 +66,11 @@ it('should render correctly if there is no data and we have an end date', () => it('should render correctly if there is no data and we have a date range', () => { renderDataTableModal({ graphEndDate: parseDate('2015-01-01'), - graphStartDate: parseDate('2014-01-01') + graphStartDate: parseDate('2014-01-01'), }); expect( screen.getByText('project_activity.graphs.data_table.no_data_warning_check_dates_x_y', { - exact: false + exact: false, }) ).toBeInTheDocument(); }); @@ -84,8 +84,8 @@ function renderDataTableModal(props: Partial<DataTableModalProps> = {}) { function mockSeries(n = 10) { const measuresHistory: MeasureHistory[] = []; const metrics: Metric[] = []; - [MetricKey.bugs, MetricKey.code_smells, MetricKey.vulnerabilities].forEach(metric => { - const history = times(n, i => { + [MetricKey.bugs, MetricKey.code_smells, MetricKey.vulnerabilities].forEach((metric) => { + const history = times(n, (i) => { const date = parseDate('2016-01-01T00:00:00+0200'); date.setDate(date.getDate() + 365 * i); return mockHistoryItem({ date, value: i.toString() }); @@ -95,7 +95,7 @@ function mockSeries(n = 10) { mockMetric({ key: metric, name: metric, - type: 'INT' + type: 'INT', }) ); }); @@ -107,7 +107,7 @@ function mockSeries(n = 10) { getDisplayedHistoryMetrics(GraphType.issues, [ MetricKey.bugs, MetricKey.code_smells, - MetricKey.vulnerabilities + MetricKey.vulnerabilities, ]) ); } diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/DefinitionChangeEventInner-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/DefinitionChangeEventInner-test.tsx index 9c5d0a62286..cd609cbfeca 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/DefinitionChangeEventInner-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/DefinitionChangeEventInner-test.tsx @@ -31,9 +31,9 @@ it('should render', () => { definitionChange: { projects: [ { changeType: 'ADDED', key: 'foo', name: 'Foo', branch: 'master' }, - { changeType: 'REMOVED', key: 'bar', name: 'Bar', branch: 'master' } - ] - } + { changeType: 'REMOVED', key: 'bar', name: 'Bar', branch: 'master' }, + ], + }, }; const wrapper = shallow(<DefinitionChangeEventInner branchLike={undefined} event={event} />); expect(wrapper).toMatchSnapshot(); @@ -57,10 +57,10 @@ it('should render for a branch', () => { key: 'bar', name: 'Bar', oldBranch: 'master', - newBranch: 'feature-y' - } - ] - } + newBranch: 'feature-y', + }, + ], + }, }; const wrapper = shallow(<DefinitionChangeEventInner branchLike={branch} event={event} />); click(wrapper.find('.project-activity-event-inner-more-link')); @@ -76,9 +76,9 @@ it('should render when readonly', () => { definitionChange: { projects: [ { changeType: 'ADDED', key: 'foo', name: 'Foo', branch: 'master' }, - { changeType: 'REMOVED', key: 'bar', name: 'Bar', branch: 'master' } - ] - } + { changeType: 'REMOVED', key: 'bar', name: 'Bar', branch: 'master' }, + ], + }, }; const wrapper = shallow( <DefinitionChangeEventInner branchLike={undefined} event={event} readonly={true} /> diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendCustom-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendCustom-test.tsx index 8a08a2dec57..c54700cf5ea 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendCustom-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendCustom-test.tsx @@ -35,20 +35,20 @@ function shallowRender(props: Partial<GraphsLegendCustomProps> = {}) { name: 'bugs', translatedName: 'Bugs', data: [{ x: parseDate('2017-05-16T13:50:02+0200'), y: 1 }], - type: 'INT' + type: 'INT', }, { name: 'my_metric', translatedName: 'My Metric', data: [{ x: parseDate('2017-05-16T13:50:02+0200'), y: 1 }], - type: 'INT' + type: 'INT', }, { name: 'foo', translatedName: 'Foo', data: [], - type: 'INT' - } + type: 'INT', + }, ]} {...props} /> diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendItem-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendItem-test.tsx index b527754561d..d2c9a3ea8d5 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendItem-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendItem-test.tsx @@ -31,7 +31,7 @@ it('should render correctly a legend', () => { index: 1, metric: 'foo', name: 'Foo', - removeMetric: jest.fn() + removeMetric: jest.fn(), }) ).toMatchSnapshot('with legend'); expect(shallowRender({ showWarning: true })).toMatchSnapshot('with warning'); diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendStatic-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendStatic-test.tsx index e4fc2d2e90e..98403cb1eb0 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendStatic-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsLegendStatic-test.tsx @@ -30,7 +30,7 @@ function shallowRender(props: Partial<GraphsLegendStaticProps> = {}) { <GraphsLegendStatic series={[ { name: 'bugs', translatedName: 'Bugs' }, - { name: 'code_smells', translatedName: 'Code Smells' } + { name: 'code_smells', translatedName: 'Code Smells' }, ]} {...props} /> diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx index b8087369c6a..d76eceafecb 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltips-test.tsx @@ -31,14 +31,14 @@ const SERIES_ISSUES = [ data: [ { x: parseDate('2011-10-01T22:01:00.000Z'), - y: 3 + y: 3, }, { x: parseDate('2011-10-25T10:27:41.000Z'), - y: 0 - } + y: 0, + }, ], - type: 'INT' + type: 'INT', }, { name: 'code_smells', @@ -46,14 +46,14 @@ const SERIES_ISSUES = [ data: [ { x: parseDate('2011-10-01T22:01:00.000Z'), - y: 18 + y: 18, }, { x: parseDate('2011-10-25T10:27:41.000Z'), - y: 15 - } + y: 15, + }, ], - type: 'INT' + type: 'INT', }, { name: 'vulnerabilities', @@ -61,27 +61,27 @@ const SERIES_ISSUES = [ data: [ { x: parseDate('2011-10-01T22:01:00.000Z'), - y: 0 + y: 0, }, { x: parseDate('2011-10-25T10:27:41.000Z'), - y: 1 - } + y: 1, + }, ], - type: 'INT' - } + type: 'INT', + }, ]; const DEFAULT_PROPS: GraphsTooltips['props'] = { events: [], - formatValue: val => 'Formated.' + val, + formatValue: (val) => 'Formated.' + val, graph: DEFAULT_GRAPH, graphWidth: 500, measuresHistory: [], selectedDate: parseDate('2011-10-01T22:01:00.000Z'), series: SERIES_ISSUES, tooltipIdx: 0, - tooltipPos: 666 + tooltipPos: 666, }; it('should render correctly for issues graphs', () => { diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContent-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContent-test.tsx index 6eb1f63865e..ab5c3cb022c 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContent-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContent-test.tsx @@ -25,7 +25,7 @@ const DEFAULT_PROPS = { index: 1, name: 'code_smells', translatedName: 'Code Smells', - value: '1.2k' + value: '1.2k', }; it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx index ca0d2dcc777..f7f1a6d1851 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentCoverage-test.tsx @@ -21,7 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { parseDate } from '../../../helpers/dates'; import GraphsTooltipsContentCoverage, { - GraphsTooltipsContentCoverageProps + GraphsTooltipsContentCoverageProps, } from '../GraphsTooltipsContentCoverage'; it('should render correctly', () => { @@ -39,23 +39,23 @@ function shallowRender(props: Partial<GraphsTooltipsContentCoverageProps> = {}) metric: 'coverage', history: [ { date: parseDate('2011-10-01T22:01:00.000Z') }, - { date: parseDate('2011-10-25T10:27:41.000Z'), value: '80.3' } - ] + { date: parseDate('2011-10-25T10:27:41.000Z'), value: '80.3' }, + ], }, { metric: 'lines_to_cover', history: [ { date: parseDate('2011-10-01T22:01:00.000Z'), value: '60545' }, - { date: parseDate('2011-10-25T10:27:41.000Z'), value: '65215' } - ] + { date: parseDate('2011-10-25T10:27:41.000Z'), value: '65215' }, + ], }, { metric: 'uncovered_lines', history: [ { date: parseDate('2011-10-01T22:01:00.000Z'), value: '40564' }, - { date: parseDate('2011-10-25T10:27:41.000Z'), value: '10245' } - ] - } + { date: parseDate('2011-10-25T10:27:41.000Z'), value: '10245' }, + ], + }, ]} tooltipIdx={1} {...props} diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentDuplication-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentDuplication-test.tsx index b17df740d20..69d82091e3b 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentDuplication-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentDuplication-test.tsx @@ -21,7 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { parseDate } from '../../../helpers/dates'; import GraphsTooltipsContentDuplication, { - GraphsTooltipsContentDuplicationProps + GraphsTooltipsContentDuplicationProps, } from '../GraphsTooltipsContentDuplication'; it('should render correctly', () => { @@ -40,9 +40,9 @@ function shallowRender(props: Partial<GraphsTooltipsContentDuplicationProps> = { metric: 'duplicated_lines_density', history: [ { date: parseDate('2011-10-01T22:01:00.000Z') }, - { date: parseDate('2011-10-25T10:27:41.000Z'), value: '10245' } - ] - } + { date: parseDate('2011-10-25T10:27:41.000Z'), value: '10245' }, + ], + }, ]} tooltipIdx={1} {...props} diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentEvents-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentEvents-test.tsx index d59e9fee197..24f8075b0cd 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentEvents-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentEvents-test.tsx @@ -23,7 +23,7 @@ import GraphsTooltipsContentEvents from '../GraphsTooltipsContentEvents'; const EVENTS = [ { key: '1', category: 'VERSION', name: '6.5' }, - { key: '2', category: 'OTHER', name: 'Foo' } + { key: '2', category: 'OTHER', name: 'Foo' }, ]; it('should render correctly', () => { diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentIssues-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentIssues-test.tsx index f8ff03bb389..b3ab3a252cb 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentIssues-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/GraphsTooltipsContentIssues-test.tsx @@ -21,7 +21,7 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { parseDate } from '../../../helpers/dates'; import GraphsTooltipsContentIssues, { - GraphsTooltipsContentIssuesProps + GraphsTooltipsContentIssuesProps, } from '../GraphsTooltipsContentIssues'; it('should render correctly', () => { @@ -38,16 +38,16 @@ function shallowRender(props: Partial<GraphsTooltipsContentIssuesProps> = {}) { metric: 'bugs', history: [ { date: parseDate('2011-10-01T22:01:00.000Z'), value: '500' }, - { date: parseDate('2011-10-25T10:27:41.000Z'), value: '1.2k' } - ] + { date: parseDate('2011-10-25T10:27:41.000Z'), value: '1.2k' }, + ], }, { metric: 'reliability_rating', history: [ { date: parseDate('2011-10-01T22:01:00.000Z') }, - { date: parseDate('2011-10-25T10:27:41.000Z'), value: '5.0' } - ] - } + { date: parseDate('2011-10-25T10:27:41.000Z'), value: '5.0' }, + ], + }, ]} name="bugs" tooltipIdx={1} diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/RichQualityGateEventInner-test.tsx b/server/sonar-web/src/main/js/components/activity-graph/__tests__/RichQualityGateEventInner-test.tsx index b4cd59e56c5..471c2ad61db 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/RichQualityGateEventInner-test.tsx +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/RichQualityGateEventInner-test.tsx @@ -29,11 +29,11 @@ const event: RichQualityGateEvent = { qualityGate: { failing: [ { branch: 'master', key: 'foo', name: 'Foo' }, - { branch: 'master', key: 'bar', name: 'Bar' } + { branch: 'master', key: 'bar', name: 'Bar' }, ], status: 'ERROR', - stillFailing: true - } + stillFailing: true, + }, }; it('should render', () => { diff --git a/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts b/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts index 4bb4c586c64..caea2f64e91 100644 --- a/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts +++ b/server/sonar-web/src/main/js/components/activity-graph/__tests__/utils-test.ts @@ -26,11 +26,11 @@ jest.mock('date-fns', () => { const actual = jest.requireActual('date-fns'); return { ...actual, - startOfDay: jest.fn(date => { + startOfDay: jest.fn((date) => { const startDay = new Date(date); startDay.setUTCHours(0, 0, 0, 0); return startDay; - }) + }), }; }); @@ -39,31 +39,31 @@ const HISTORY = [ metric: MetricKey.lines_to_cover, history: [ { date: dates.parseDate('2017-04-27T08:21:32.000Z'), value: '100' }, - { date: dates.parseDate('2017-04-30T23:06:24.000Z'), value: '100' } - ] + { date: dates.parseDate('2017-04-30T23:06:24.000Z'), value: '100' }, + ], }, { metric: MetricKey.uncovered_lines, history: [ { date: dates.parseDate('2017-04-27T08:21:32.000Z'), value: '12' }, - { date: dates.parseDate('2017-04-30T23:06:24.000Z'), value: '50' } - ] - } + { date: dates.parseDate('2017-04-30T23:06:24.000Z'), value: '50' }, + ], + }, ]; const METRICS = [ { id: '1', key: MetricKey.uncovered_lines, name: 'Uncovered Lines', type: 'INT' }, - { id: '2', key: MetricKey.lines_to_cover, name: 'Line to Cover', type: 'PERCENT' } + { id: '2', key: MetricKey.lines_to_cover, name: 'Line to Cover', type: 'PERCENT' }, ]; const SERIE: Serie = { data: [ { x: dates.parseDate('2017-04-27T08:21:32.000Z'), y: 2 }, - { x: dates.parseDate('2017-04-28T08:21:32.000Z'), y: 2 } + { x: dates.parseDate('2017-04-28T08:21:32.000Z'), y: 2 }, ], name: 'foo', translatedName: 'Foo', - type: 'PERCENT' + type: 'PERCENT', }; describe('generateCoveredLinesMetric', () => { @@ -78,7 +78,7 @@ describe('generateSeries', () => { expect( utils.generateSeries(HISTORY, GraphType.coverage, METRICS, [ MetricKey.uncovered_lines, - MetricKey.lines_to_cover + MetricKey.lines_to_cover, ]) ).toMatchSnapshot(); }); @@ -93,11 +93,11 @@ describe('getDisplayedHistoryMetrics', () => { expect(utils.getDisplayedHistoryMetrics(utils.DEFAULT_GRAPH, [])).toEqual([ MetricKey.bugs, MetricKey.code_smells, - MetricKey.vulnerabilities + MetricKey.vulnerabilities, ]); expect(utils.getDisplayedHistoryMetrics(GraphType.coverage, customMetrics)).toEqual([ MetricKey.lines_to_cover, - MetricKey.uncovered_lines + MetricKey.uncovered_lines, ]); }); it('should return all custom metrics for the custom graph', () => { @@ -116,12 +116,12 @@ describe('getHistoryMetrics', () => { MetricKey.vulnerabilities, MetricKey.reliability_rating, MetricKey.security_rating, - MetricKey.sqale_rating + MetricKey.sqale_rating, ]); expect(utils.getHistoryMetrics(GraphType.coverage, customMetrics)).toEqual([ MetricKey.lines_to_cover, MetricKey.uncovered_lines, - GraphType.coverage + GraphType.coverage, ]); expect(utils.getHistoryMetrics(GraphType.custom, customMetrics)).toEqual(customMetrics); }); @@ -137,9 +137,9 @@ describe('hasHistoryData', () => { type: 'INT', data: [ { x: dates.parseDate('2017-04-27T08:21:32.000Z'), y: 2 }, - { x: dates.parseDate('2017-04-30T23:06:24.000Z'), y: 2 } - ] - } + { x: dates.parseDate('2017-04-30T23:06:24.000Z'), y: 2 }, + ], + }, ]) ).toBe(true); expect( @@ -148,7 +148,7 @@ describe('hasHistoryData', () => { name: 'foo', translatedName: 'foo', type: 'INT', - data: [] + data: [], }, { name: 'bar', @@ -156,9 +156,9 @@ describe('hasHistoryData', () => { type: 'INT', data: [ { x: dates.parseDate('2017-04-27T08:21:32.000Z'), y: 2 }, - { x: dates.parseDate('2017-04-30T23:06:24.000Z'), y: 2 } - ] - } + { x: dates.parseDate('2017-04-30T23:06:24.000Z'), y: 2 }, + ], + }, ]) ).toBe(true); expect( @@ -167,8 +167,8 @@ describe('hasHistoryData', () => { name: 'bar', translatedName: 'bar', type: 'INT', - data: [{ x: dates.parseDate('2017-04-27T08:21:32.000Z'), y: 2 }] - } + data: [{ x: dates.parseDate('2017-04-27T08:21:32.000Z'), y: 2 }], + }, ]) ).toBe(false); }); 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 4c84246e277..22b94853464 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 @@ -30,20 +30,20 @@ export const DEFAULT_GRAPH = GraphType.issues; const GRAPHS_METRICS_DISPLAYED: Dict<string[]> = { [GraphType.issues]: [MetricKey.bugs, MetricKey.code_smells, MetricKey.vulnerabilities], [GraphType.coverage]: [MetricKey.lines_to_cover, MetricKey.uncovered_lines], - [GraphType.duplications]: [MetricKey.ncloc, MetricKey.duplicated_lines] + [GraphType.duplications]: [MetricKey.ncloc, MetricKey.duplicated_lines], }; const GRAPHS_METRICS: Dict<string[]> = { [GraphType.issues]: GRAPHS_METRICS_DISPLAYED[GraphType.issues].concat([ MetricKey.reliability_rating, MetricKey.security_rating, - MetricKey.sqale_rating + MetricKey.sqale_rating, ]), [GraphType.coverage]: [...GRAPHS_METRICS_DISPLAYED[GraphType.coverage], MetricKey.coverage], [GraphType.duplications]: [ ...GRAPHS_METRICS_DISPLAYED[GraphType.duplications], - MetricKey.duplicated_lines_density - ] + MetricKey.duplicated_lines_density, + ], }; export function isCustomGraph(graph: GraphType) { @@ -56,11 +56,11 @@ export function getGraphTypes(ignoreCustom = false) { } export function hasDataValues(serie: Serie) { - return serie.data.some(point => Boolean(point.y || point.y === 0)); + return serie.data.some((point) => Boolean(point.y || point.y === 0)); } export function hasHistoryData(series: Serie[]) { - return series.some(serie => serie.data && serie.data.length > 1); + return series.some((serie) => serie.data && serie.data.length > 1); } export function getSeriesMetricType(series: Serie[]) { @@ -76,13 +76,13 @@ export function getHistoryMetrics(graph: GraphType, customMetrics: string[]) { } export function hasHistoryDataValue(series: Serie[]) { - return series.some(serie => serie.data && serie.data.length > 1 && hasDataValues(serie)); + return series.some((serie) => serie.data && serie.data.length > 1 && hasDataValues(serie)); } export function splitSeriesInGraphs(series: Serie[], maxGraph: number, maxSeries: number) { return flatMap( - groupBy(series, serie => serie.type), - type => chunk(type, maxSeries) + groupBy(series, (serie) => serie.type), + (type) => chunk(type, maxSeries) ).slice(0, maxGraph); } @@ -90,17 +90,19 @@ export function generateCoveredLinesMetric( uncoveredLines: MeasureHistory, measuresHistory: MeasureHistory[] ) { - const linesToCover = measuresHistory.find(measure => measure.metric === MetricKey.lines_to_cover); + const linesToCover = measuresHistory.find( + (measure) => measure.metric === MetricKey.lines_to_cover + ); return { data: linesToCover ? uncoveredLines.history.map((analysis, idx) => ({ x: analysis.date, - y: Number(linesToCover.history[idx].value) - Number(analysis.value) + y: Number(linesToCover.history[idx].value) - Number(analysis.value), })) : [], name: 'covered_lines', translatedName: translate('project_activity.custom_metric.covered_lines'), - type: 'INT' + type: 'INT', }; } @@ -115,23 +117,23 @@ export function generateSeries( } return sortBy( measuresHistory - .filter(measure => displayedMetrics.indexOf(measure.metric) >= 0) - .map(measure => { + .filter((measure) => displayedMetrics.indexOf(measure.metric) >= 0) + .map((measure) => { if (measure.metric === MetricKey.uncovered_lines && !isCustomGraph(graph)) { return generateCoveredLinesMetric(measure, measuresHistory); } const metric = findMetric(measure.metric, metrics); return { - data: measure.history.map(analysis => ({ + data: measure.history.map((analysis) => ({ x: analysis.date, - y: metric && metric.type === 'LEVEL' ? analysis.value : Number(analysis.value) + y: metric && metric.type === 'LEVEL' ? analysis.value : Number(analysis.value), })), name: measure.metric, translatedName: metric ? getLocalizedMetricName(metric) : localizeMetric(measure.metric), - type: metric ? metric.type : 'INT' + type: metric ? metric.type : 'INT', }; }), - serie => + (serie) => displayedMetrics.indexOf(serie.name === 'covered_lines' ? 'uncovered_lines' : serie.name) ); } @@ -155,13 +157,13 @@ export function getActivityGraph( const customGraphs = get(`${namespace}.custom`, project); return { graph: (get(namespace, project) as GraphType) || DEFAULT_GRAPH, - customGraphs: customGraphs ? customGraphs.split(',') : [] + customGraphs: customGraphs ? customGraphs.split(',') : [], }; } export function getAnalysisEventsForDate(analyses: ParsedAnalysis[], date?: Date) { if (date) { - const analysis = analyses.find(a => a.date.valueOf() === date.valueOf()); + const analysis = analyses.find((a) => a.date.valueOf() === date.valueOf()); if (analysis) { return analysis.events; } @@ -171,7 +173,7 @@ export function getAnalysisEventsForDate(analyses: ParsedAnalysis[], date?: Date function findMetric(key: string, metrics: Metric[] | Dict<Metric>) { if (Array.isArray(metrics)) { - return metrics.find(metric => metric.key === key); + return metrics.find((metric) => metric.key === key); } return metrics[key]; } |