Skip to content

c8 ignore next comment does not quite appropriately compensate for branches #254

Description

@Trott
  • Version: v14.12.0
  • Platform: macOS Darwin Kernel Version 19.6.0

Given this code in index.js:

function fn() {
  return true;
  /* c8 ignore next */
  console.log('never runs');
}

fn();

Running with ci node index.js, I get this output:

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |    66.67 |     100 |     100 |                   
 index.js |     100 |    66.67 |     100 |     100 | 2                 
----------|---------|----------|---------|---------|-------------------

I would expect the branches to all be considered covered since the entire uncovered branch is excluded by the c8 ignore comment.

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |    100 |     100 |     100 |                   
 index.js |     100 |    100 |     100 |     100 | 2                 
----------|---------|----------|---------|---------|-------------------

Activity

  1. Trott commented on Sep 25, 2020

    @Trott
    ContributorAuthor

    Even simpler reproduction:

    return true;
    /* c8 ignore next */
    console.log('never runs');
  2. bcoe commented on Oct 1, 2020

    @bcoe
    Owner

    thanks @Trott 👍 will try to get to this in the not too distant future 🚀

  3. bcoe commented on Oct 8, 2020

    @bcoe
    Owner

    this should be fixed in [email protected].

  4. reopened this on Oct 8, 2020
  5. bcoe commented on Oct 8, 2020

    @bcoe
    Owner

    unfortunately this caused a regression with TypeScript, tldr; source maps are the worst.

  6. Trott commented on Oct 8, 2020

    @Trott
    ContributorAuthor

    unfortunately this caused a regression with TypeScript, tldr; source maps are the worst.

    NOOOOOOOOoooooooooooo,,,,....!!!!!

  7. bcoe commented on Oct 16, 2020

    @bcoe
    Owner

    @Trott wow, it too me this long to get to this message in my inbox 😆

    I have a cunning plan, I was thinking we could perhaps check if the covered range is only 1 character, at which point I think it's a good indicator I've detected a \n character.

    I'll play with this soon.

  8. added a commit that references this issue on Oct 24, 2020
    167ff2d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions