Ruby on Rails + SimpleCov - File not found in the system

Hi! We are working on a project based on Ruby on Rails and are using Github Actions to scan every push with Sonarcloud.

We’ve just configured everything and every scan is running smoothly, but in every pullrequest we got the message “No Coverage information”, so we read the docs and set the “sonar.ruby.coverage.reportPaths” variable at “sonar-project.properties” file.

But when reading the logs, we got this WARN:


INFO: 1107/1107 source files have been analyzed
INFO: Sensor Ruby Sensor [ruby] (done) | time=50175ms
INFO: Sensor SimpleCov Sensor for Ruby coverage [ruby]
WARN: File ‘/home/runner/work/panel-backend/panel-backend/app/models/center_custom_domain.rb’ is present in coverage report but cannot be found in filesystem
WARN: File ‘/home/runner/work/panel-backend/panel-backend/app/models/cash_flow.rb’ is present in coverage report but cannot be found in filesystem
WARN: File ‘/home/runner/work/panel-backend/panel-backend/app/controllers/api/v3/activities_controller.rb’ is present in coverage report but cannot be found in filesystem

For every file. Sonar is scanning the files ok, and all of them are appearing at the dashboard.

How can we debug the issue? Do you have any advice?

Thanks a lot in advance!

Hi,

Did you generate report on the same machine as you run analysis? If not absolute paths in the report might be different from the real ones during analysis.

I am having same issue too.

I am having this issue also - has anyone found a solution?

The problem is that my RSpec and coverage reports are run in a Docker container in the following path:

“/usr/src/app”

so the resulting simplecov .resultset.json has the files all listed in that path.

Sonar is not ran in Docker so the path to the files is different.

I assumed Sonar was complaining as it could not find the files in this path, so I used a script to manipulate the .resultset.json file and replace all the “/usr/src/app” with the correct local directory that Sonar is running in.

But I am still getting the error on every file not being found, even though the files are correct.

e.g.

WARN: File 'app/services/detail_service.rb' is present in coverage report but cannot be found in filesystem.

What way does Sonar expect the paths to be like?

I was finally able to resolve this by replacing the path in the SimpleCov results file, with the Bamboo working directory path.

I was able to use a Bamboo environment variable for the replacement. Now Sonar can see the files in the filesystem, it must need an absolute path in Bamboo/

e.g.
original path was: “/usr/src/app”
new path was: “/home/bamboo/bamboo-agent-home/xml-data/build-dir/SDBG4987-DSR”