missing coverage of closing brace when `return` ends a `switch/case`
See original GitHub issue- Version: tested on 8.15.1, 10.15.3, 11.14.0, 12.0.0, 13.0.0-pre
- Platform: Darwin Fhqwhgads.local 17.7.0 Darwin Kernel Version 17.7.0: Wed Feb 27 00:43:23 PST 2019; root:xnu-4570.71.35~1/RELEASE_X86_64 x86_64
Code in foo.js:
function checkIt(arg) {
switch (arg) {
case true:
return 'It was true!';
case false:
return 'It as not true';
}
return 'It was neither true nor false';
}
const val1 = checkIt(true);
const val2 = checkIt(false);
const val3 = checkIt('string');
console.log(val1);
console.log(val2);
console.log(val3);
Command:
c8 node foo.js
Output:
It was true!
It as not true
It was neither true nor false
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 94.12 | 71.43 | 100 | 94.12 | |
foo.js | 94.12 | 71.43 | 100 | 94.12 | 7 |
Expected output:
I expected to see 100% coverage...
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
c++: switch statement missing semicolon before close brace
Because you need a statement for your default case. A semicolon is an empty-statement.
Read more >Closing braces sometimes not being included in code coverage
Hi all,I am experiencing an issue with dotCover where, in some circumstances, the closing brace of a method/constructor is highlighted as...
Read more >Optional Braces - Scala 3 - EPFL
This rule is helpful for finding missing closing braces. ... In each case, the : at the end of line can be replaced...
Read more >EXP19-C. Use braces for the body of an if, for, or while statement
Opening and closing braces for if , for , and while statements should always be used even if the statement's body contains only...
Read more >code coverage issue with brace | Apple Developer Forums
The line is a closing brace (highlighted in red below). ... May be you are missing a general catch statement, for all cases...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Trott hey, I remember this bit of the codebase,
https://github.com/v8/v8/commit/deac757bc76d207845375340bcea090c774ad9d0
Let’s cherry-pick that commit 😄
I think this has been fixed in V8 although awaiting a release?