monocart-coverage-reports
Advanced tools
Comparing version 2.10.2 to 2.10.3
@@ -149,3 +149,5 @@ const Util = require('../utils/util.js'); | ||
const addBranch = (group, node, locationMap) => { | ||
const { start, end } = node; | ||
const { | ||
start, end, type | ||
} = node; | ||
@@ -163,2 +165,20 @@ const branchKey = `${group.start}_${group.end}`; | ||
if (type === 'SwitchCase') { | ||
// console.log(node); | ||
// check break | ||
if (node.consequent) { | ||
const breakItem = node.consequent.find((it) => it.type === 'BreakStatement'); | ||
if (breakItem) { | ||
branchInfo.hasBreak = true; | ||
} | ||
} | ||
// check default | ||
if (!node.test) { | ||
branchInfo.isDefault = true; | ||
} | ||
} | ||
group.locations.push(branchInfo); | ||
@@ -188,3 +208,3 @@ | ||
let blockCount = 0; | ||
locations.forEach((item) => { | ||
locations.forEach((item, i) => { | ||
if (item.block) { | ||
@@ -195,2 +215,4 @@ item.count = item.block.count; | ||
} | ||
// for calculate mo break branches | ||
item.index = i; | ||
noBlockList.push(item); | ||
@@ -247,9 +269,30 @@ }); | ||
const SwitchStatement = (group, parentCount) => { | ||
const { noBlockList, blockCount } = updateBlockLocations(group.locations); | ||
const locations = group.locations; | ||
const { noBlockList, blockCount } = updateBlockLocations(locations); | ||
if (!noBlockList.length) { | ||
return; | ||
} | ||
const count = parentCount - blockCount; | ||
// calculate switch/case count | ||
const countLeft = parentCount - blockCount; | ||
noBlockList.forEach((item) => { | ||
item.count = count; | ||
let hasCount = false; | ||
// check no break branches | ||
for (let i = item.index - 1; i >= 0; i--) { | ||
const b = locations[i]; | ||
if (b && !b.hasBreak && b.count > 0) { | ||
item.count += b.count; | ||
hasCount = true; | ||
continue; | ||
} | ||
break; | ||
} | ||
if (!hasCount) { | ||
item.count = countLeft; | ||
} | ||
}); | ||
@@ -256,0 +299,0 @@ }; |
{ | ||
"name": "monocart-coverage-reports", | ||
"version": "2.10.2", | ||
"version": "2.10.3", | ||
"description": "A code coverage tool to generate native V8 reports or Istanbul reports.", | ||
@@ -86,3 +86,3 @@ "main": "./lib/index.js", | ||
"eight-colors": "^1.3.0", | ||
"foreground-child": "^3.2.1", | ||
"foreground-child": "^3.3.0", | ||
"istanbul-lib-coverage": "^3.2.2", | ||
@@ -99,3 +99,3 @@ "istanbul-lib-report": "^3.0.1", | ||
"esbuild": "^0.23.0", | ||
"eslint": "~9.8.0", | ||
"eslint": "~9.9.0", | ||
"eslint-config-plus": "^2.0.2", | ||
@@ -113,3 +113,3 @@ "eslint-plugin-html": "^8.1.1", | ||
"supports-color": "^9.4.0", | ||
"tsx": "^4.16.5", | ||
"tsx": "^4.17.0", | ||
"turbogrid": "^3.2.0", | ||
@@ -116,0 +116,0 @@ "vine-ui": "^3.1.16", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
941640
11026
Updatedforeground-child@^3.3.0