Skip to content

Commit

Permalink
fix: wrong output of clover for other types
Browse files Browse the repository at this point in the history
  • Loading branch information
KiritaniAyaka committed Nov 7, 2022
1 parent f4925c2 commit 66db410
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions packages/istanbul-reports/lib/clover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,33 @@ class CloverReport extends ReportBase {
};
const branchDetail = branchDetails[k];

if (branchDetail && branchDetail.type === 'if') {
attrs.type = 'cond';
if (!branchDetail || branchDetail.type === 'switch') {
return this.xml.inlineTag('line', attrs);
}

attrs.type = 'cond';
attrs.truecount = 0;
attrs.falsecount = 0;

if (count === 0) {
return this.xml.inlineTag('line', attrs);
}

if (['if', 'cond-expr'].includes(branchDetail.type)) {
attrs.truecount = branchDetail.states[0];
attrs.falsecount = branchDetail.states[1];
} else if (
['binary-expr', 'default-arg'].includes(branchDetail.type)
) {
if (branchDetail.states.every(state => state > 0)) {
attrs.truecount = 1;
attrs.falsecount = 1;
} else {
attrs.truecount = 1;
attrs.falsecount = 0;
}
}

this.xml.inlineTag('line', attrs);
});

Expand Down

0 comments on commit 66db410

Please sign in to comment.