SonarQube report showing a different coverage than Gitlab RSpec (Ruby) report

Just as the title implies we’re dealing with an “issue” regarding the information shown in SonarQube for our Ruby Code Coverage when we compare it to the Gitlab Pipeline job execution given that in the Pipe execution it’s showing

as you can see it shows 91.21% coverage/covered

While in SonarQube we’re getting the following result:

Which is weird given that they are both supposedly taking reading the same report

We’re using SimpleCov 0.21.1 and only made some minor adjustment to the report in order to avoid using the “branches” feature that came after simplecov 0.18+.

Maybe those are 2 different values and not related at all and I’m getting it all wrong? Any help or guidance would be greatly appreciated :’)

Thanks a lot in advance and happy new year in advance :D!

PS: The version we’re using in SonarQube 9.2.4

Hi Christian,

Welcome to the Community! :smiley:

There are a couple of reasons coverage metrics in SonarQube can be different to raw coverage provided by coverage tools:

  1. SonarQube’s coverage metric uses a combination of line coverage and condition coverage (details here). A quick check of SimpleCov suggests that it only uses line coverage
  2. SonarQube uses the Executable Lines metric to take into account lines from files that don’t appear in the coverage report at all (see the blog post here). You can see this in the 1991 LOC shown by SimpleCov vs. the 2.8k New Lines to cover metric shown in your SonarQube screen shot

I hope this clarifies; let me know if you have more questions.

Regards,

Cameron.

2 Likes

Thanks a lot @Cameron this clarified the whole thing for me hahaha
Will consider this for future implementations and make the adjustments accordingly.

Happy to help! :smiley:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.