bcoe / bcoe/c8

Lines without statements (empty lines) on them are counted as statements

Open
#500 6 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.1k
Forks
99
PR merge metrics
No merged PRs in 30d

Description

* **Version**: v18.14.2
* **Platform**:
```
Darwin BL-mmillerick-NNH946444W 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 arm64
```
I've noticed that `c8` does not distinguish between number of lines and number of statements. I switched a large project from `nyc` to `c8`, 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 how `nyc` and `c8` gather the coverage information, but I did not expect the number of statements to equal the number of lines.
![image](https://github.com/bcoe/c8/assets/26394493/181e1cbf-e663-4c37-8d70-e6e99291b29d)

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:
![image](https://github.com/bcoe/c8/assets/26394493/35b5d104-4f5b-4ff1-a187-a5ab899cec36)

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?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the coverage report from the linked minimal c8 TypeScript example and compare its empty-line and statement counts with the reported expectation. Review c8's coverage-reporting behavior and documentation; done means empty lines are no longer counted as statements while the existing line and statement metrics remain correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.