Unable to load the Simplecov results to Sonarqube

Sonarqube Version:
Community Edition Version 8.9.5 (build 50698)

Simplecov gem version:
gem 'simplecov', '~> 0.21.2'

Inside spec/spec_helper.rb

require 'simplecov'
require "simplecov_json_formatter"
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
  SimpleCov::Formatter::HTMLFormatter,
  SimpleCov::Formatter::JSONFormatter
])
SimpleCov.start

Command to scan:

    sonar-scanner \
    -D sonar.host.url=http://localhost:55003 \
    -D sonar.login=token \
    -D sonar.sources=. \
    -D sonar.ruby.coverage.reportPaths=coverage/coverage.json \
    -D sonar.projectBaseDir=/base/path \
    -D sonar.projectName=name \
    -D sonar.projectKey=key \

Trying to import the Simplecov results into Sonarqube but getting the error:

WARN: File 'FILE/PATH' is present in coverage report but cannot be found in filesystem

Also tried with full path.
Note: I’m using the docker image to run sonarqube.

Hi,

Welcome to the community!

The paths in your coverage report need to match the paths analysis sees. Do they? Or are you generating the coverage report in one environment and trying to import it in another (with slightly different paths)?

 
Ann

Sonarqube:
I’m using the sonarqube server from docker.
And once the server is started, it provided this command for scanning.

sonar-scanner \
    -D sonar.host.url=http://localhost:55003 \
    -D sonar.login=token \
    -D sonar.sources=. \
    -D sonar.ruby.coverage.reportPaths=coverage/coverage.json \
    -D sonar.projectBaseDir=/base/path \
    -D sonar.projectName=name \
    -D sonar.projectKey=key \

My project root directory is:
/Users/myuser/backend/appname

I used this command in my project directory for scanning.

Simplecov:

I have simplecov gem installed and I ran all the rspecs, at the end of this run, the coverage report is generated at coverage/coverage.json.

The coverage.json looks like this:

{
  "meta": {
    "simplecov_version": "0.21.2"
  },
  "coverage": {
    "/appname/app/admin/admin_user.rb": {
      "lines": [
        1,
        1,
        null,
...

Hi,

You need to open the report itself and look at the paths.

 
Ann

Which report you are referring to?

The one that’s not loading…