question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
bcoecommented, Sep 19, 2019

@Trott hey, I remember this bit of the codebase,

https://github.com/v8/v8/commit/deac757bc76d207845375340bcea090c774ad9d0

Let’s cherry-pick that commit 😄

0reactions
Trottcommented, Sep 19, 2019

I think this has been fixed in V8 although awaiting a release?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found