skrbp
(Shekhar)
October 10, 2022, 9:05am
1
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.
ganncamp
(G Ann Campbell)
October 12, 2022, 12:11pm
2
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
skrbp
(Shekhar)
October 12, 2022, 1:01pm
3
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,
...
ganncamp
(G Ann Campbell)
October 12, 2022, 1:12pm
4
Hi,
You need to open the report itself and look at the paths.
Ann
skrbp
(Shekhar)
October 12, 2022, 1:14pm
5
Which report you are referring to?
ganncamp
(G Ann Campbell)
October 12, 2022, 1:20pm
6
The one that’s not loading…
According to sonar8.9 docs Test coverage and execution You have to pass Comma-delimited list of paths to SimpleCov report files generated with the json formatter for simplecov version 0.20 onwards.
As your version is higher can you update **-D sonar.ruby.coverage.reportPaths ** path in sonarscan accordingly
1 Like