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

Newlines after a return statement considered to be uncovered code #151

Closed
Avaq opened this issue Oct 10, 2019 · 2 comments
Closed

Newlines after a return statement considered to be uncovered code #151

Avaq opened this issue Oct 10, 2019 · 2 comments

Comments

@Avaq
Copy link

Avaq commented Oct 10, 2019

System information

$ uname -a
Linux thinkpad-avaq 4.19.75 #1-NixOS SMP Sat Sep 21 05:17:15 UTC 2019 x86_64 GNU/Linux
$ node -v
v12.11.1

(also tested on Node 12.5.0)

Description

In some cases (see below), c8 considers the newlines after a return statement to be "uncovered code".

Steps to reproduce

  1. Install c8:

    $ npm install c8
  2. Write the following content to src/index.mjs:

    const f = ({}) => {
      const b = {};
      return;
    }
    
    f ({});
  3. Write the following content to test/index.mjs:

    import '../src/index.mjs'
  4. Run c8:

    $ c8 node --experimental-modules test/index.mjs 
    (node:4857) ExperimentalWarning: The ESM module loader is experimental.
    -----------|----------|----------|----------|----------|-------------------|
    File       |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
    -----------|----------|----------|----------|----------|-------------------|
    All files  |      100 |    66.67 |      100 |      100 |                   |
     index.mjs |      100 |    66.67 |      100 |      100 |                 3 |
    -----------|----------|----------|----------|----------|-------------------|

Expected result

I expect to see no uncovered lines.

Actual result

Line 3 ( return;) is considered "partially covered". If I add additional newlines after the return statement, they come up as fully uncovered lines. If I remove the statement prior to the return statement, the problem goes away. If I stop using destructuring in the function arguments, the problem also goes away.

Possible related issues

@Avaq Avaq changed the title c8 considers the newlines after a return statement to be uncovered code Newlines after a return statement considered to be uncovered code Oct 10, 2019
@bcoe
Copy link
Owner

bcoe commented Oct 24, 2019

this is likely an issue with the upstream v8 engine.

@bcoe bcoe added the duplicate label Nov 29, 2019
@bcoe bcoe closed this as completed Nov 29, 2019
@bcoe
Copy link
Owner

bcoe commented Nov 29, 2019

I've confirmed that this is the same issue as #66, fix incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants