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

behavior change suggestion/rfc: statusbar should report Math.floor instead of Math.round #423

Closed
guppy0130 opened this issue Sep 11, 2023 · 1 comment · Fixed by #426
Closed
Assignees
Labels
Milestone

Comments

@guppy0130
Copy link
Contributor

guppy0130 commented Sep 11, 2023

Is your feature request related to a problem? Please describe.

I open a file with 200 LoC, 1 line uncovered. I expect the summary to not say "100% Coverage," since there's a line missing.

It currently does say 100% though, because $\frac{199}{200} * 100=99.5$, and that rounds to $100$.

Describe the solution you'd like

If there's interest/folks are okay with it, I think this line:

return this.statusBar.setCoverage(Math.round((covered / total) * 100 ));

should be changed from Math.round to Math.floor. I'll file a PR for this later today, but wanted to raise the issue too for visibility

Describe alternatives you've considered

  • not changing it - but this leads to the current slightly misleading output

Additional context

N/A

guppy0130 added a commit to guppy0130/vscode-coverage-gutters that referenced this issue Sep 17, 2023
* in a 200 line file with 1 missed line, statusbar would report 100%
  coverage with `Math.round`, which is misleading; there is still one
  missed line, so use `Math.floor` instead (which would report 99%
  coverage)
@ryanluker
Copy link
Owner

@guppy0130 Thanks for the ticket and the PR!
Logic + math looks good to me, I will take at a look at the PR today.

@ryanluker ryanluker added the bug label Sep 17, 2023
@ryanluker ryanluker added this to the 2.12.0 milestone Sep 17, 2023
@ryanluker ryanluker removed their assignment Sep 17, 2023
@ryanluker ryanluker linked a pull request Sep 17, 2023 that will close this issue
@ryanluker ryanluker modified the milestones: 2.12.0, 2.11.1 Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants