-
Notifications
You must be signed in to change notification settings - Fork 91
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
Lines without statements (empty lines) on them are counted as statements #500
Comments
@bcoe , can you comment on this and whether or not it is possible to change this behavior? |
@millerick I'm not quite sure what my reasoning was for the logic here: I believe a line object is added for each line (correctly) but we also iterate over all these lines turning them into statements. It may be that, if a line has no statements on it, we could skip it. |
Meaning do not create statements for lines that do not actually have a statement on them? |
I spent some time trying to look at this, and while it is easy to get line 4 to count as neither a statement nor a line, I can't find a way to get it to count as a line but not a statement. I tried looking through other code bases I have that are still using I do think that having empty lines not counted as either lines or statements is more correct than the current behavior. @bcoe , if you agree, I will submit a pull request for that change. However, I am unsure if it is possible to make the total number of lines/statements differ from each other in |
I am encountering the same problem. I use c8 and jest to measure coverage and upload them to Codecov. Is there a way or setting to combine the coverage measured by jest (or any other tool using Istanbul instrumentation) with the coverage measured by c8? |
For now, my problem is resolved configuring https://jestjs.io/ja/docs/configuration#coverageprovider-string to "v8" . |
I've noticed that
c8
does not distinguish between number of lines and number of statements. I switched a large project fromnyc
toc8
, and noticed that both the number of lines and the number of statements dramatically increased as part of the switch. Number of lines I understand due to the differences in hownyc
andc8
gather the coverage information, but I did not expect the number of statements to equal the number of lines.I put together a minimal example in
https://github.com/millerick/c8-ts-line-statement-example
The coverage report for it is also committed to that repository, but here is a screenshot of it:
Here I do not expect line 4 to be counted as a statement. I also would not expect lines 3 or 7 to be counted as statements, but am less opinionated about that.
I read through
c8
's documentation and did not find any configuration settings I could change to produce the behavior I expected. Is there something that I am missing? Is there a way to improve this so that only lines with actual code statements on them are counted as statements?The text was updated successfully, but these errors were encountered: