Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add placeholder to fix Implicit Else #679

Merged
merged 5 commits into from Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/istanbul-reports/lib/html/annotator.js
Expand Up @@ -142,6 +142,23 @@ function annotateBranches(fileCoverage, structuredText) {
// only highlight if partial branches are missing or if there is a
// single uncovered branch.
if (sumCount > 0 || (sumCount === 0 && branchArray.length === 1)) {
// Need to recover the metaArray placeholder item to count an implicit else
if (
// Check if the branch is a conditional if branch.
branchMeta[branchName].type === 'if' &&
// Check if the branch has an implicit else.
branchArray.length === 2 &&
adrian-burlacu-software marked this conversation as resolved.
Show resolved Hide resolved
// Check if the implicit else branch is unnacounted for.
metaArray.length === 1 &&
// Check if the implicit else branch is uncovered.
branchArray[1] === 0
) {
metaArray[1] = {
start: {},
end: {}
};
}

for (
i = 0;
i < branchArray.length && i < metaArray.length;
Expand Down
5 changes: 0 additions & 5 deletions packages/istanbul-reports/test/fixtures/github-649.json
Expand Up @@ -100,11 +100,6 @@
"line": 6,
"column": 5
}
}, {
adrian-burlacu-software marked this conversation as resolved.
Show resolved Hide resolved
"start": {
},
"end": {
}
}
],
"line": 4
Expand Down