sometimes covered_percent in .last_run.json value is different from html formatter's one
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
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!
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