Skip to content

Commit

Permalink
refactor initLineCoverage
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Aug 1, 2024
1 parent b400514 commit d656c24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/converter/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ const handleLinesCoverage = (bytes, locator, ignoredRanges) => {
return;
}

lineItem.coveredCount = 1;
lineItem.uncoveredEntire = null;
lineItem.uncoveredPieces = [];
Util.initLineCoverage(lineItem);

lineMap.set(line, lineItem);
});

Expand Down
6 changes: 6 additions & 0 deletions lib/platform/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,12 @@ const Util = {
return lines;
},

initLineCoverage: (lineItem) => {
lineItem.coveredCount = 1;
lineItem.uncoveredEntire = null;
lineItem.uncoveredPieces = [];
},

updateLinesCoverage: (lines, count, lineMap) => {
lines.forEach((it) => {
const lineItem = lineMap.get(it.line);
Expand Down
5 changes: 2 additions & 3 deletions packages/app/src/utils/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ class CoverageParser {
}
// 1-base
const line = lineItem.line + 1;
lineItem.coveredCount = 1;
lineItem.uncoveredEntire = null;
lineItem.uncoveredPieces = [];

Util.initLineCoverage(lineItem);

// need set `ignore` line, and will add ignoredCount
lineItem.ignored = this.isLineIgnored(lineItem, formattedIgnores);
Expand Down

0 comments on commit d656c24

Please sign in to comment.