]> source.dussan.org Git - sonarqube.git/commitdiff
Code smells fixes
authorPhilippe Perrin <philippe.perrin@sonarsource.com>
Thu, 9 Jan 2020 08:10:41 +0000 (09:10 +0100)
committerSonarTech <sonartech@sonarsource.com>
Mon, 13 Jan 2020 19:46:37 +0000 (20:46 +0100)
server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerReviewHistoryTab.tsx
server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/FilterBar-test.tsx

index 7796b5e41d0a5c3c000c7469a1589e48ad120d58..07989ed42f7aaaae7a66d35b91a4372a778ea6ea 100644 (file)
@@ -38,9 +38,9 @@ export default function HotspotViewerReviewHistoryTab(props: HotspotViewerReview
 
   return (
     <div className="padded">
-      {history.map((elt, i) => (
-        <React.Fragment key={i}>
-          {i > 0 && <hr />}
+      {history.map((elt, historyIndex) => (
+        <React.Fragment key={historyIndex}>
+          {historyIndex > 0 && <hr />}
           <div className="padded">
             <div className="display-flex-center">
               {elt.user.name && (
@@ -74,8 +74,8 @@ export default function HotspotViewerReviewHistoryTab(props: HotspotViewerReview
 
             {elt.type === ReviewHistoryType.Diff && elt.diffs && (
               <div className="spacer-top">
-                {elt.diffs.map((diff, i) => (
-                  <IssueChangelogDiff diff={diff} key={i} />
+                {elt.diffs.map((diff, diffIndex) => (
+                  <IssueChangelogDiff diff={diff} key={diffIndex} />
                 ))}
               </div>
             )}
index 8a7a32c18779b14e86700e3a73498224e5d64342..ad65adf0343213feee13329575ba902700fb8795 100644 (file)
@@ -54,10 +54,11 @@ it('should trigger onChange for status', () => {
     .props();
 
   if (!onChange) {
-    return fail("Select's onChange should be defined");
+    fail("Select's onChange should be defined");
+  } else {
+    onChange({ value: HotspotStatusFilter.SAFE });
+    expect(onChangeFilters).toBeCalledWith({ status: HotspotStatusFilter.SAFE });
   }
-  onChange({ value: HotspotStatusFilter.SAFE });
-  expect(onChangeFilters).toBeCalledWith({ status: HotspotStatusFilter.SAFE });
 });
 
 it('should trigger onChange for self-assigned toggle', () => {
@@ -67,10 +68,11 @@ it('should trigger onChange for self-assigned toggle', () => {
   const { onCheck } = wrapper.find(RadioToggle).props();
 
   if (!onCheck) {
-    return fail("RadioToggle's onCheck should be defined");
+    fail("RadioToggle's onCheck should be defined");
+  } else {
+    onCheck(AssigneeFilterOption.ALL);
+    expect(onChangeFilters).toBeCalledWith({ assignedToMe: false });
   }
-  onCheck(AssigneeFilterOption.ALL);
-  expect(onChangeFilters).toBeCalledWith({ assignedToMe: false });
 });
 
 it('should trigger onChange for leak period', () => {
@@ -83,10 +85,11 @@ it('should trigger onChange for leak period', () => {
     .props();
 
   if (!onChange) {
-    return fail("Select's onChange should be defined");
+    fail("Select's onChange should be defined");
+  } else {
+    onChange({ value: true });
+    expect(onChangeFilters).toBeCalledWith({ sinceLeakPeriod: true });
   }
-  onChange({ value: true });
-  expect(onChangeFilters).toBeCalledWith({ sinceLeakPeriod: true });
 });
 
 function shallowRender(props: Partial<FilterBarProps> = {}) {