From b986abff6dc9b2d435efa02d5f2a8b6600254060 Mon Sep 17 00:00:00 2001 From: Revanshu Paliwal Date: Tue, 20 Sep 2022 17:13:08 +0200 Subject: [PATCH] SONAR-16906 Elements must only use allowed ARIA attributes --- .../SourceViewer/components/LineCoverage.tsx | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx index ee151802289..c5d69b53b40 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx @@ -47,37 +47,33 @@ export function LineCoverage({ line, scrollToUncoveredLine }: LineCoverageProps) return ( -
+
); } function getStatusTooltip(line: SourceLine) { - if (line.coverageStatus === 'uncovered') { - if (line.conditions) { - return translateWithParameters('source_viewer.tooltip.uncovered.conditions', line.conditions); - } else { - return translate('source_viewer.tooltip.uncovered'); - } - } else if (line.coverageStatus === 'covered') { - if (line.conditions) { - return translateWithParameters('source_viewer.tooltip.covered.conditions', line.conditions); - } else { - return translate('source_viewer.tooltip.covered'); - } - } else if (line.coverageStatus === 'partially-covered') { - if (line.conditions) { - return translateWithParameters( - 'source_viewer.tooltip.partially-covered.conditions', - line.coveredConditions || 0, - line.conditions - ); - } else { - return translate('source_viewer.tooltip.partially-covered'); - } + switch (line.coverageStatus) { + case 'uncovered': + return line.conditions + ? translateWithParameters('source_viewer.tooltip.uncovered.conditions', line.conditions) + : translate('source_viewer.tooltip.uncovered'); + case 'covered': + return line.conditions + ? translateWithParameters('source_viewer.tooltip.covered.conditions', line.conditions) + : translate('source_viewer.tooltip.covered'); + case 'partially-covered': + return line.conditions + ? translateWithParameters( + 'source_viewer.tooltip.partially-covered.conditions', + line.coveredConditions || 0, + line.conditions + ) + : translate('source_viewer.tooltip.partially-covered'); + default: + return undefined; } - return undefined; } export default React.memo(LineCoverage); -- 2.39.5