c8 icon indicating copy to clipboard operation
c8 copied to clipboard

Issue with overlapping ignore rules

Open mikecbrant opened this issue 4 years ago • 1 comments

  • Version: c8 version 7.3.5
  • npm --versions { npm: '7.3.0', node: '15.5.0', v8: '8.6.395.17-node.23', uv: '1.40.0', zlib: '1.2.11', brotli: '1.0.9', ares: '1.17.1', modules: '88', nghttp2: '1.41.0', napi: '7', llhttp: '2.1.3', openssl: '1.1.1i', cldr: '38.0', icu: '68.1', tz: '2020b', unicode: '13.0' }
  • Platform: node:latest image from DockerHub, running in Bitbucket Pipelines

We have started to get code coverage related failures in our build environments, correlated to our build environment moving from Node 15.4 to 15.5 from 'node:latest' DockerHub image.

Suddenly code coverage that was passing has begun failing with lines that we attempt to ignore showing as uncovered.

When looking at these new cases of uncovered lines, we are noticing this happening around cases where we have what are actually overlapping ignore directives set.

For example, one of the cases that surfaced was in the code below.

/* c8 ignore next 82 */
const cloneStoreConfigMap = (map, optsDecorator) => {
  /* c8 ignore next */
  const decoratorFn = optsDecorator || ( (storeOpts) => storeOpts );
 ...
}

Note how the 4th line shown here is actually ignored by both directives. They overlap. What we are finding happening now is that it seems these overlap cases are now causing the prior directive to be turned off. So we show the 2nd line above as covered. It may actually be exercised in our tests, so not sure if this is because of next 82 directive or actual code execution). The lines starting with the 5th line (my ... above) until the end of the 82-line function are now showing as uncovered.

Now obviously we have some sloppy use of our ignores here that we need to clean up, but just wanted to open the issue, as nothing in the documentation would lead me to believe these overlapping ignore directives should not work.

mikecbrant avatar Dec 30 '20 18:12 mikecbrant

@mikecbrant, @connorjclark has been working on some functionality around being able to start/stop ignoring lines.

For starters, I think you might want to try out this functionality, vs., the ignore 82.

Secondly, I'm betting there's a chance we introduce a bug while adding this functionality. Any chance you can figure out a reproduction in v8-to-istanbul?

bcoe avatar Dec 30 '20 23:12 bcoe