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

Let's report actionable minimum numbers for Branch Coverage #1115

Open
corsonknowles opened this issue Nov 2, 2024 · 4 comments
Open

Let's report actionable minimum numbers for Branch Coverage #1115

corsonknowles opened this issue Nov 2, 2024 · 4 comments

Comments

@corsonknowles
Copy link

corsonknowles commented Nov 2, 2024

Currently, simplecov is rounding up when delivering branch coverage results. If we then set minimum branch coverage to the reported amount, the next spec run will fail.

Example:

Line Coverage: 100.0% (3486 / 3486)
Branch Coverage: 98.2% (763 / 777)
Running RuboCop...
Inspecting 281 files

763 / 777 = 0.98198198198

So the ideal number for the report would be 98.19, i.e. the floor of the 2nd decimal place.

Running specs with 98.19 will pass, as expected.

gem list simplecov

*** LOCAL GEMS ***

simplecov (0.22.0)
simplecov-html (0.13.1, 0.12.3)
simplecov_json_formatter (0.1.4)

Reproduction steps:
Set up Rubocop RSpec

Run bundle exec rake

Check out this branch if you want to reproduce with the exact coverage metrics described here:

@corsonknowles
Copy link
Author

I think we can accomplish this by changing:
https://github.com/simplecov-ruby/simplecov/blob/b6c2d4208a5fa395ce09d7e1d3b074f680ee29b0/lib/simplecov/formatter/simple_formatter.rb#L17C75-L17C80
output << "#{file.filename} (coverage: #{file.covered_percent.round(2)}%)\n"

to use .floor(2) rather than round(2)

@corsonknowles
Copy link
Author

Digging around (haha, yes pun intended) a little bit, it looks like almost all other occurrences of this issue were handled here:

@corsonknowles
Copy link
Author

Hi Tobias!
Can we get your help with this?
@PragTob

@corsonknowles
Copy link
Author

corsonknowles commented Nov 21, 2024

Here's a potential fix:

(regardless of whether it fixes this specific issue, it moves us closer to consistency and having actionable numbers to set min coverage with)

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

No branches or pull requests

1 participant