Sonarqube 7.5.0 Ruby and Simplecov no show coverage

  • versions used (7.5.0, Scanner, Code Analyzer for Ruby 1.5.0,
  • I run the tests first
$ bundle exec rspec spec 
Run options: exclude {:slow=>true}
.........................................*....................................*.............................................*

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Assignments::AuthenticateWithCertificate#call The SII is not available Should raise a Savon::HTTPError
     # Temporarily skipped with xit
     # ./spec/services/assignments/authenticate_with_certificate_spec.rb:62

  2) Assignments::ReassignInvoice#execute When the 'Validate Delivery' operation fails Should return a Failure response
     # Temporarily skipped with xit
     # ./spec/services/assignments/reassign_invoice_spec.rb:244

  3) Documents::CheckDigitalCertificate verify file.ppfx the digital certificate path is wrong
     # Temporarily skipped with xit
     # ./spec/services/documents/xml/check_digital_certificate_spec.rb:26


Finished in 1 minute 6.71 seconds (files took 4.76 seconds to load)
125 examples, 0 failures, 3 pending

Coverage report generated for RSpec to /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby/projects/portal-finance-assignment-api/coverage. 990 / 1130 LOC (87.61%) covered.
  • then I run the sonar-scanner and it tells me that it has no coverage
INFO: Scanner configuration file: /home/bitnami/sonar-scanner-3.2.0.1227-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby/sonar-project.properties
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Linux 4.9.0-8-amd64 amd64
INFO: User cache: /home/bitnami/.sonar/cache
INFO: SonarQube server 7.5.0
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=460ms
INFO: Server id: 80865CDB-AWgN5ctocsMekjGDtfBc
INFO: User cache: /home/bitnami/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=416ms
INFO: Load/download plugins (done) | time=2183ms
INFO: Loaded core extensions: 
INFO: Sonargraph Integration: Custom metrics file '/home/bitnami/.sonargraphintegration/metrics.properties' not found
INFO: Sonargraph Integration: Created 54 predefined and 0 custom metric(s)
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=4ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=492ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=422ms
INFO: Load active rules
INFO: Load active rules (done) | time=5815ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=393ms
INFO: Project key: assignment-api
INFO: Project base dir: /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby
INFO: ------------- Scan assignment-api
INFO: Base dir: /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby
INFO: Working dir: /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby/.scannerwork
INFO: Source paths: projects/portal-finance-assignment-api
INFO: Test paths: projects/portal-finance-assignment-api
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Excluded sources: 
INFO: projects/portal-finance-assignment-api/*.spec.ts
INFO: Included tests: 
INFO: projects/portal-finance-assignment-api/*.spec.ts
INFO: 495 files indexed
INFO: 495 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for css: Sonar way
INFO: Quality profile for js: Sonar way
INFO: Quality profile for ruby: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Sensor SonarCSS Metrics [cssfamily]
INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=117ms
INFO: Sensor SonarCSS Rules [cssfamily]
  ERROR: Failed to get Node.js version. No CSS files will be analyzed.
  java.io.IOException: Cannot run program "node": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at java.lang.Runtime.exec(Runtime.java:620)
    at java.lang.Runtime.exec(Runtime.java:450)
    at java.lang.Runtime.exec(Runtime.java:347)
    at org.sonar.css.plugin.CssRuleSensor.checkCompatibleNodeVersion(CssRuleSensor.java:138)
    at org.sonar.css.plugin.CssRuleSensor.execute(CssRuleSensor.java:94)
    at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:62)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:319)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
    at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
  Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 36 common frames omitted
INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=7ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=5ms
INFO: Sensor SonarJS [javascript]
INFO: 4 source files to be analyzed
INFO: Sensor SonarJS [javascript] (done) | time=8823ms
INFO: Sensor ESLint-based SonarJS [javascript]
INFO: 4/4 source files have been analyzed
INFO: Using default Node.js executable: 'node'.
  ERROR: Failure during analysis, Node.js command to start eslint-bridge server was not built yet.
    org.sonarsource.nodejs.NodeCommandException: Error when starting the process: node -v
    at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:75)
    at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:172)
    at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:145)
    at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:121)
    at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServer(EslintBridgeServerImpl.java:114)
    at org.sonar.plugins.javascript.eslint.EslintBasedRulesSensor.execute(EslintBasedRulesSensor.java:81)
    at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:62)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:319)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:82)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
    at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
  Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:144)
    at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:71)
    ... 36 common frames omitted
  Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 38 common frames omitted
INFO: Sensor ESLint-based SonarJS [javascript] (done) | time=834ms
INFO: Sensor Ruby Sensor [ruby]
INFO: 145 source files to be analyzed
INFO: 145/145 source files have been analyzed
INFO: Sensor Ruby Sensor [ruby] (done) | time=8516ms
INFO: Sensor SimpleCov Sensor for Ruby coverage [ruby]
INFO: Sensor SimpleCov Sensor for Ruby coverage [ruby] (done) | time=1ms
INFO: Sensor JavaXmlSensor [java]
INFO: 180 source files to be analyzed
WARN: Invalid character encountered in file /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby/projects/portal-finance-assignment-api/public/uploads/assignment_process/aec/1419cac8-fe95-4902-8411-5bb6aa1927ac/aec-155473321520190408-20472-nht9pq.xml at line 220 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
WARN: Invalid character encountered in file /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby/projects/portal-finance-assignment-api/public/uploads/assignment_process/aec/2d444d3f-5fca-4492-8517-03923cc5ecc2/aec-155438653020190404-27263-1i8fift.xml at line 220 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
WARN: Invalid character encountered in file /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby/projects/portal-finance-assignment-api/public/uploads/assignment_process/aec/4a1090b7-901a-4b9c-a2f0-4cb35a2e72d3/aec-155449600420190405-21544-16qblrw.xml at line 220 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
WARN: Invalid character encountered in file /home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby/projects/portal-finance-assignment-api/public/uploads/assignment_process/aec/907bdce8-f817-4492-8ad0-2300f1e52100/aec-155432674620190403-18363-1l3yon.xml at line 220 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.
INFO: Sensor JavaXmlSensor [java] (done) | time=1355ms
INFO: Sensor Sonargraph Integration [sonargraphintegration]
INFO: 180/180 source files have been analyzed
INFO: Sonargraph Integration: Processing project 'assignment-api'
WARN: Sonargraph Integration: XML report file '/home/bitnami/sonar-scanner-3.2.0.1227-linux/bin/ruby/target/sonargraph/sonargraph-sonarqube-report.xml' not found

I don’t see in the logs message about missing coverage. Is it in SonarQube UI?

Try to run in debug mode (sonar-scanner -X) and also provide your sonar-project.properties files.

To import the coverage you need to set the property sonar.ruby.coverage.reportPaths, for example in the sonar-project.properties files:

sonar.ruby.coverage.reportPaths=coverage/.resultset.json

See Ruby Coverage Results Import

1 Like

I did this, but the value in SonarQube is different from the local .resultset.json file. Can I please know if this is something to do with ‘sonar.sources’ files that I import or anything else.
The files showing lines of coverage are more in SonarQube and less locally.
Thank you in advance.

Hello @Koshila-cd

Can you give provide us the different versions you are using (mainly the SonarQube version, and the SimpleCov version), the logs of the analysis and more details concerning the differences you are observing?

My guess is that you are using a version of SimpleCov > 0.17, which is currently not supported. See
SONARSLANG-477 for more details. When SonarQube fails to import the coverage report, it will compute an approximation of the lines to cover (with all lines marked as “uncovered”). This could explain the differences.

As described in the ticket, there is now a clear way to solve this problem: using the JSON formatter. We are currently working on it, it will be available soon.