Ruby SimpleCov coverage counts empty lines and "end" line

We use SimpleCov for coverage report, and coverage shown in SonarCloud is different than those in SimpleCov original report (which gets imported into Sonar).
We noticed that Sonar is reporting many more lines than SimpleCov original, and thus coverage drops down. Further investigating, we noticed that Sonar is counting empty lines and lines having “end” as end block, and marking those as not covered.
Is there a setting or workaround for this, since we would like to use Sonar for all our metrics across projects and technologies?

Adding sample screenshot:

Hello Sasa,

Thanks for your feedback. I would need your help because I failed to reproduce this coverage report bug.

SonarRuby should never count empty lines or lines having “end”. SonarRuby has two cases:

  1. When SimpleCov produces data in coverage/.resultset.json related to a ruby file, SonarRuby uses it:
    1-cov85

  2. When SimpleCov produces NO data in coverage/.resultset.json related to a ruby file (that is not a test file), SonarRuby has to generate uncovered lines for it:
    1-cov0

Above example are generated using SonarRuby 1.5 and SimpleCov 0.16.1.

Could you try to add a simple file to your project that you will be able to share with us and that reproduces this wrong coverage report? We would also need your version number of SonarRuby and SimpleCov. And the blocs of data in your coverage/.resultset.json that is related to the simple file.

Regards,

Alban

3 Likes