# Ruby SimpleCov coverage counts empty lines and "end" line

**URL:** <https://community.sonarsource.com/t/ruby-simplecov-coverage-counts-empty-lines-and-end-line/10797>\
**Category:** SonarQube Cloud\
**Tags:** ruby, coverage\
**Created:** [June 14, 2019, 5:27am UTC](https://community.sonarsource.com/t/ruby-simplecov-coverage-counts-empty-lines-and-end-line/10797 "2019-06-14T05:27:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasasalamon](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sasasalamon/32/4615_2.png) [@sasasalamon](https://community.sonarsource.com/u/sasasalamon)\
**Post date:** [June 14, 2019, 5:27am UTC](https://community.sonarsource.com/t/ruby-simplecov-coverage-counts-empty-lines-and-end-line/10797/1 "2019-06-14T05:27:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sasasalamon](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sasasalamon/32/4615_2.png) [@sasasalamon](https://community.sonarsource.com/u/sasasalamon)\
**Post date:** [June 28, 2019, 6:09am UTC](https://community.sonarsource.com/t/ruby-simplecov-coverage-counts-empty-lines-and-end-line/10797/5 "2019-06-28T06:09:36Z")

</div>

Adding sample screenshot:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/2/25fed2b23d99f8c09dd9352f1cac4aa9261bf391.png)

---

<div class="post-metadata">

**Author:** ![alban.auzeill](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/alban.auzeill/32/36_2.png) [@alban.auzeill](https://community.sonarsource.com/u/alban.auzeill)\
**Post date:** [July 1, 2019, 6:01am UTC](https://community.sonarsource.com/t/ruby-simplecov-coverage-counts-empty-lines-and-end-line/10797/6 "2019-07-01T06:01:32Z")

</div>

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](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/f/f4c3f8eeb38f17c5666bda737fd3302d7eabdec7.png)

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](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/f/f8e4815e720343e307d28e521570316de49c7b10.png)

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

---

<div class="post-metadata">

**Author:** ![pftg](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/pftg/32/21709_2.png) [@pftg](https://community.sonarsource.com/u/pftg)\
**Post date:** [April 29, 2021, 5:19pm UTC](https://community.sonarsource.com/t/ruby-simplecov-coverage-counts-empty-lines-and-end-line/10797/7 "2021-04-29T17:19:43Z")

</div>

Still the issue for simplecov (0.21.2) + simplecov\_json\_formatter (0.1.2)
