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

sometimes covered_percent in .last_run.json value is different from html formatter's one #948

Open
koki1023 opened this issue Nov 29, 2020 · 1 comment
Labels

Comments

@koki1023
Copy link

Hi there,

Due to #679 fix, covered_percent in .last_run.json value is different from html formatter's one.

For examle,
covered_percent in .last_run.json shows 14.21
But, simplecov-html shows 14.22

Code_coverage_for_Repro

In simplecov-html the coverage percentage is rounded by .round(2) like below search results.
https://github.com/simplecov-ruby/simplecov-html/search?q=.round%282%29

In contrast to it, simplecov is flooring its coverage percent like below.
https://github.com/simplecov-ruby/simplecov/blob/main/lib/simplecov.rb#L291-L297

MY SUGGESTION

compute_percent method In coverage_statistics.rb returns like this,
SimpleCov.round_coverage(covered * 100.0 / total)
https://github.com/simplecov-ruby/simplecov/blob/main/lib/simplecov/coverage_statistics.rb#L47

Infos

  • simplecov: 0.19.1
  • simplecov-html: 0.12.3
  • ruby -e "puts RUBY_DESCRIPTION"": ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
  • the gem versions of Rails: 6.0.0

Thanks!

@PragTob PragTob added the Bug label Nov 29, 2020
@PragTob
Copy link
Collaborator

PragTob commented Nov 29, 2020

Hi there,

yes you're right - thanks for the bug report!

I don't like the suggested approach though - I think that method and the data available should always be the not rounded value. Rounding it there might introduce further surprises.

we could make a separate rounded value available (lots of duplication) or probably better provide a public method that does simplecov rounding on percentages and replace all round calls fir display with it.

Cheers,
Tobi

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

No branches or pull requests

2 participants