]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16906 Elements must only use allowed ARIA attributes
authorRevanshu Paliwal <revanshu.paliwal@sonarsource.com>
Tue, 20 Sep 2022 15:13:08 +0000 (17:13 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 22 Sep 2022 20:03:32 +0000 (20:03 +0000)
server/sonar-web/src/main/js/components/SourceViewer/components/LineCoverage.tsx

index ee15180228926a01f50370583f2952927c6c2800..c5d69b53b40257a8cd3c4071fda47d2032c61dbb 100644 (file)
@@ -47,37 +47,33 @@ export function LineCoverage({ line, scrollToUncoveredLine }: LineCoverageProps)
   return (
     <td className={className} data-line-number={line.line} ref={coverageMarker}>
       <Tooltip overlay={status} placement="bottom">
-        <div aria-label={status} className="source-line-bar" />
+        <div aria-label={status} role="img" className="source-line-bar" />
       </Tooltip>
     </td>
   );
 }
 
 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);