From affb3ba985d80d93edb3dac3d5b1baff6ca996ea Mon Sep 17 00:00:00 2001 From: cenfun Date: Sun, 30 Jun 2024 14:01:17 +0800 Subject: [PATCH] fix sonar issue --- lib/converter/converter.js | 20 +++++++++++--------- lib/platform/share.js | 11 ++++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/converter/converter.js b/lib/converter/converter.js index 3e6e4135..d2bd919e 100644 --- a/lib/converter/converter.js +++ b/lib/converter/converter.js @@ -1239,15 +1239,17 @@ const initJsCoverageList = (item) => { inUncoveredRange.coveredList.push(range); } } - } else { - if (count === 0) { - uncoveredBlocks.push({ - ... range, - index: i, - ranges: block.ranges - }); - } + return; } + + if (count === 0) { + uncoveredBlocks.push({ + ... range, + index: i, + ranges: block.ranges + }); + } + }); }); @@ -1283,7 +1285,7 @@ const initJsCoverageList = (item) => { }); } - ranges.splice.apply(ranges, args); + ranges.splice(... args); }); } diff --git a/lib/platform/share.js b/lib/platform/share.js index c7322f83..958ebe11 100644 --- a/lib/platform/share.js +++ b/lib/platform/share.js @@ -347,12 +347,13 @@ const Util = { // 2, uncovered entire and pieces if (count > 0) { lineItem.coveredCount = Math.max(lineItem.coveredCount, count); + return; + } + + if (it.entire) { + lineItem.uncoveredEntire = it; } else { - if (it.entire) { - lineItem.uncoveredEntire = it; - } else { - lineItem.uncoveredPieces.push(it); - } + lineItem.uncoveredPieces.push(it); } });