From e174fc4437e276857bd7b820f905515bc9ce29f1 Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Thu, 9 Jan 2020 09:10:41 +0100 Subject: [PATCH] Code smells fixes --- .../HotspotViewerReviewHistoryTab.tsx | 10 ++++----- .../components/__tests__/FilterBar-test.tsx | 21 +++++++++++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerReviewHistoryTab.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerReviewHistoryTab.tsx index 7796b5e41d0..07989ed42f7 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerReviewHistoryTab.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotViewerReviewHistoryTab.tsx @@ -38,9 +38,9 @@ export default function HotspotViewerReviewHistoryTab(props: HotspotViewerReview return (
- {history.map((elt, i) => ( - - {i > 0 &&
} + {history.map((elt, historyIndex) => ( + + {historyIndex > 0 &&
}
{elt.user.name && ( @@ -74,8 +74,8 @@ export default function HotspotViewerReviewHistoryTab(props: HotspotViewerReview {elt.type === ReviewHistoryType.Diff && elt.diffs && (
- {elt.diffs.map((diff, i) => ( - + {elt.diffs.map((diff, diffIndex) => ( + ))}
)} diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/FilterBar-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/FilterBar-test.tsx index 8a7a32c1877..ad65adf0343 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/FilterBar-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/__tests__/FilterBar-test.tsx @@ -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 = {}) { -- 2.39.5