simplecov icon indicating copy to clipboard operation
simplecov copied to clipboard

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

Open koki1023 opened this issue 5 years ago • 1 comments

Hi there,

Due to https://github.com/simplecov-ruby/simplecov/issues/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!

koki1023 avatar Nov 29 '20 15:11 koki1023

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

PragTob avatar Nov 29 '20 17:11 PragTob