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

Reporting of empty lines as not covered #112

Closed
ir-fuel opened this issue Jun 8, 2019 · 4 comments
Closed

Reporting of empty lines as not covered #112

ir-fuel opened this issue Jun 8, 2019 · 4 comments

Comments

@ir-fuel
Copy link

ir-fuel commented Jun 8, 2019

  • Version: Node v10.15.3
  • Platform: Darwin Kernel Version 18.5.0

After running my tests I get a coverage report that reports empty lines as being uncovered.

This is one of the files where it does this:

const config = require("config");
const logger = require("./logger");

const geocoderConfig = config.geocoder
const apiKey = geocoderConfig.apiKey;
const extra = {
  apiKey: apiKey,
  timeout: 30000
};

const geocoder = require("node-geocoder")("google", "https", extra);

exports.geocode = (address, zip, city, country) => {

  let params = {
    address: address + ' ' + zip + ' ' + city + ' ' + country
  };

  return new Promise((resolve, reject) => {
    geocoder.geocode(
      params, (error, result) => {

        /* c8 ignore next 3 */
        if (error) {
          logger.error("Error geocoding: " + JSON.stringify({error, result}, null, 3));
          return reject(error);
        }

        /* c8 ignore next 5 */
        if (!result || result.length === 0)
          return resolve({
            latitude: null,
            longitude: null
          });

        resolve({
          latitude: result[0].latitude,
          longitude: result[0].longitude
        });
      });
  });
};

The empty line right above c8 ignore next 3 is reported as uncovered

---------------------------|----------|----------|----------|----------|-------------------|
File                       |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
---------------------------|----------|----------|----------|----------|-------------------|
All files                  |    78.38 |    64.79 |    84.99 |    78.38 |                   |
  geocoder.js              |    97.62 |    71.43 |      100 |    97.62 |                22 |

I also have other files where it reports closing braces as uncovered, e.g. at the end of a file I have

      })
  })
}

and those 3 lines are reported as uncovered.

@shinnn
Copy link
Contributor

shinnn commented Jun 8, 2019

Try to create a minimal reproduction. It would be very helpful if you can provide an example with 10 lines or smaller. ref. #61 (comment)

Also, don't leave us guessing. The code at least should have told us how the exported geocode function is called.

@ir-fuel
Copy link
Author

ir-fuel commented Jun 9, 2019

Ok nvm. I removed esm from my project, converted all import statements to require and I'm back to using Istanbul.

@ir-fuel ir-fuel closed this as completed Jun 9, 2019
@shinnn
Copy link
Contributor

shinnn commented Jun 9, 2019

As long as #112 (comment) lacks the information you're using esm and the example contains no import statement, we could never provide any useful feedback for you because we were hardly able to guess both of them from the issue description.

@sramam
Copy link

sramam commented Sep 23, 2020

Please see for a simple reproduction.
https://github.com/sramam/c8-empty-lines

My experiments seem to indicate that it only happens for files that export * ....

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

No branches or pull requests

3 participants