ClassCastException trying to add SimpleCov to Dashboard Coverage

Similar to this almost identical post, I was following the fix but got almost the same error.

Exception

ERROR: Cannot read coverage report file, expecting standard SimpleCov resultset JSON format: 'coverage/.resultset.json'
java.lang.ClassCastException: class org.sonarsource.analyzer.commons.internal.json.simple.JSONObject cannot be cast to class org.sonarsource.analyzer.commons.internal.json.simple.JSONArray (org.sonarsource.analyzer.commons.internal.json.simple.JSONObject and org.sonarsource.analyzer.commons.internal.json.simple.JSONArray are in unnamed module of loader org.sonar.classloader.ClassRealm @214894fc)
	at org.sonarsource.ruby.plugin.SimpleCovSensor.mergeFrameworkCoverages(SimpleCovSensor.java:121)
	at org.sonarsource.ruby.plugin.SimpleCovSensor.mergeFileCoverages(SimpleCovSensor.java:114)
	at org.sonarsource.ruby.plugin.SimpleCovSensor.execute(SimpleCovSensor.java:71)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.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.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
	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.doAfterStart(GlobalContainer.java:141)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	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:189)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)

JSON

{"timestamp":1600440235,"command_name":"RSpec","files":[{"filename":"path/lib/mytool/app/controllers/application_controller.rb","covered_percent":86.20689655172414,"coverage":{"lines":[null,null,1,1,1,null,1,105,9,null,null,null,null,null,null,105,0,null,null,null,null,null,null,null,1,9,null,null,null,1,263,263,161,102,73,null,29,null,null,null,1,0,null,null,1,0,null,null,1,0,null,null,1,null,1,40,null,null,1,5,null,1,null]},"covered_strength":40.58620689655172,"covered_lines":25,"lines_of_code":29},{"filename":"path/lib/mytool/app/controllers/client_tokens_controller.rb","covered_percent":97.43589743589743,"coverage":{"lines":[null,null,1,1,1,1,null,1,2,null,null,1,4,null,4,4,null,4,2,2,null,2,null,1,null,null,null,1,2,2,null,2,2,1,1,null,1,null,null,null,1,10,8,null,8,null,0,null,null,1,null,1,18,null,null,1,3,3,null,null,1,6,null,null,1,2,2,null,null]},"covered_strength":2.7948717948717947,"covered_lines":38,"lines_of_code":39},{"filename":"path/lib/mytool/app/controllers/concerns/internal_user_devise_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,3,null,null]},"covered_strength":1.6666666666666667,"covered_lines":3,"lines_of_code":3},{"filename":"path/lib/mytool/app/controllers/concerns/multi_model_login_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,5,null,null,1,null,1,78,77,null,null]},"covered_strength":20.625,"covered_lines":8,"lines_of_code":8},{"filename":"path/lib/mytool/app/controllers/confirmations_controller.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,null,1,null,1,4,4,3,null,1,null,null,null,1,null,1,2,2,null,null,1,4,null,null]},"covered_strength":2.0,"covered_lines":13,"lines_of_code":13},{"filename":"path/lib/mytool/app/controllers/internal/auth/omniauth_callbacks_controller.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,1,1,null,null,null,1,5,3,3,3,null,2,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,null,null,null,null,null,1,5,4,null,null,null,1,5,null,null,null,null,null,null]},"covered_strength":2.2941176470588234,"covered_lines":17,"lines_of_code":17},{"filename":"path/lib/mytool/app/controllers/internal/auth/sessions_controller.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,1,1,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]},"covered_strength":1.0,"covered_lines":6,"lines_of_code":6},{"filename":"path/lib/mytool/app/controllers/internal/organizations_controller.rb","covered_percent":80.68181818181819,"coverage":{"lines":[null,null,1,1,1,null,1,5,null,5,5,null,null,1,2,1,1,null,null,null,1,null,null,null,null,null,1,1,null,null,null,1,2,null,2,2,null,2,1,1,1,null,null,1,0,null,1,null,null,0,0,null,null,null,1,9,null,9,null,null,1,3,null,null,1,4,null,4,0,0,4,3,3,null,1,1,null,null,null,1,1,1,1,1,null,0,0,null,null,null,1,2,2,null,2,2,0,0,null,0,null,null,null,1,null,1,3,3,3,3,null,0,null,null,null,1,0,0,0,null,0,null,null,null,1,1,null,null,1,4,null,4,null,null,1,5,null,null,1,3,null,0,null,null,1,6,null,null,1,9,null,null,null,1,2,null,0,null,null,1,7,null,null,null,null,null,null]},"covered_strength":1.8522727272727273,"covered_lines":71,"lines_of_code":88},{"filename":"path/lib/mytool/app/controllers/internal/registered_organizations_controller.rb","covered_percent":96.92307692307692,"coverage":{"lines":[null,null,1,1,1,null,1,4,4,4,1,null,3,null,null,null,1,4,4,null,4,2,2,2,1,null,1,null,1,null,1,null,null,null,1,1,1,null,null,1,2,2,null,2,1,1,null,1,null,1,null,null,null,1,2,2,null,2,1,null,1,null,null,2,null,null,1,3,3,null,3,2,1,1,null,0,null,null,null,1,null,1,2,2,null,2,2,null,null,1,1,0,null,1,1,null,1,null,1,null,null,1,16,null,null,1,3,null,null,1,6,null,null,null,null,null]},"covered_strength":1.9384615384615385,"covered_lines":63,"lines_of_code":65},{"filename":"path/lib/mytool/app/controllers/internal/taggings_controller.rb","covered_percent":95.0,"coverage":{"lines":[null,null,1,1,1,null,1,6,6,4,null,2,null,null,6,null,null,1,2,2,2,null,0,null,null,2,null,null,1,null,null,1,8,null,null,1,6,null,null,null]},"covered_strength":2.7,"covered_lines":19,"lines_of_code":20},{"filename":"path/lib/mytool/app/controllers/internal/tags_controller.rb","covered_percent":85.71428571428571,"coverage":{"lines":[null,null,1,1,1,null,1,0,0,null,null,1,4,4,2,null,2,null,4,null,null,1,1,1,1,null,0,null,1,null,null,1,null,1,4,null,null,null]},"covered_strength":1.5238095238095237,"covered_lines":18,"lines_of_code":21},{"filename":"path/lib/mytool/app/controllers/internal/users_controller.rb","covered_percent":97.14285714285714,"coverage":{"lines":[null,null,1,null,1,1,1,null,1,15,null,15,15,null,null,1,10,null,null,1,5,5,null,null,1,2,2,2,1,1,null,1,1,null,null,null,1,1,1,null,1,1,1,null,0,null,null,null,1,1,1,2,null,null,null,1,null,1,2,null,null,null]},"covered_strength":2.8,"covered_lines":34,"lines_of_code":35},{"filename":"path/lib/mytool/app/controllers/organizations_controller.rb","covered_percent":85.71428571428571,"coverage":{"lines":[null,null,1,1,null,1,1,null,null,1,1,1,1,1,null,0,0,null,null,null,1,null,1,1,null,null]},"covered_strength":0.8571428571428571,"covered_lines":12,"lines_of_code":14},{"filename":"path/lib/mytool/app/controllers/portal_controller.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,null,1,14,null,null]},"covered_strength":4.25,"covered_lines":4,"lines_of_code":4},{"filename":"path/lib/mytool/app/controllers/public_controller.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,null]},"covered_strength":1.0,"covered_lines":2,"lines_of_code":2},{"filename":"path/lib/mytool/app/controllers/public_keys_controller.rb","covered_percent":89.65517241379311,"coverage":{"lines":[null,null,1,1,1,1,1,null,1,1,null,null,1,1,1,1,null,1,1,null,1,null,null,null,null,null,1,1,null,0,null,null,null,1,0,null,null,1,2,2,null,2,null,0,null,null,1,null,null,1,0,0,null,null,null,1,1,null,null,1,1,null,null,null,1,0,0,null,null,null]},"covered_strength":1.0689655172413792,"covered_lines":26,"lines_of_code":29},{"filename":"path/lib/mytool/app/controllers/users/passwords_controller.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,null,1,1,1,null,null,null,null,null,null,1,4,4,3,null,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,4,null,null,null]},"covered_strength":1.9166666666666667,"covered_lines":12,"lines_of_code":12},{"filename":"path/lib/mytool/app/controllers/users/registrations_controller.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,1,null,1,3,1,1,1,2,null,2,null,null,null,1,null,1,3,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]},"covered_strength":1.4285714285714286,"covered_lines":14,"lines_of_code":14},{"filename":"path/lib/mytool/app/controllers/users/sessions_controller.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]},"covered_strength":1.0,"covered_lines":4,"lines_of_code":4},{"filename":"path/lib/mytool/app/helpers/address_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1288,null,null]},"covered_strength":430.0,"covered_lines":3,"lines_of_code":3},{"filename":"path/lib/mytool/app/helpers/application_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,266,null,null,1,2,null,null,1,2,null,1,null,null,1,1,null,null,1,446,null,null,1,2,null,null,1,10,null,7,7,null,null]},"covered_strength":41.77777777777778,"covered_lines":18,"lines_of_code":18},{"filename":"path/lib/mytool/app/helpers/devise_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,28,10,null,1,null,null,1,9,null,null,null,null,null,null,null,null,1,1,null,null,null,null,null,null,null,null]},"covered_strength":5.888888888888889,"covered_lines":9,"lines_of_code":9},{"filename":"path/lib/mytool/app/helpers/internal/nav_helper.rb","covered_percent":87.03703703703704,"coverage":{"lines":[null,null,1,1,1,0,null,null,1,16,null,null,1,14,0,14,0,14,0,14,0,null,14,null,14,null,null,1,4,0,4,0,null,4,null,4,null,null,1,18,13,null,5,null,null,null,1,18,null,null,1,18,null,null,1,18,null,null,1,18,null,null,1,18,null,null,1,18,null,null,1,32,null,null,1,32,null,null,1,32,null,null,1,32,null,null,1,18,null,null,1,22,null,null,1,22,null,null,null]},"covered_strength":8.703703703703704,"covered_lines":47,"lines_of_code":54},{"filename":"path/lib/mytool/app/helpers/internal/tags_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,1,null,null,null]},"covered_strength":1.0,"covered_lines":4,"lines_of_code":4},{"filename":"path/lib/mytool/app/helpers/internal/users_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,1,11,null,null,null]},"covered_strength":3.5,"covered_lines":4,"lines_of_code":4},{"filename":"path/lib/mytool/app/helpers/mailer_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,2,null,null]},"covered_strength":1.3333333333333333,"covered_lines":3,"lines_of_code":3},{"filename":"path/lib/mytool/app/helpers/organizations_helper.rb","covered_percent":100.0,"coverage":{"lines":[null,null,1,1,41,null,null,1,6,null,null,1,6,null,null,1,3,null,null,1,56,429,null,null,null,1,7,6,null,1,null,null,null,1,7,1,null,6,null,null,null]},"covered_strength":28.85,"covered_lines":20,"lines_of_code":20}],"metrics":{"covered_percent":94.0,"covered_strength":10.137142857142857,"covered_lines":987,"total_lines":1050}}

sonar-project.properties

sonar.projectKey="KEY"
sonar.projectName="Mytool"
sonar.sources="app,config,db,lib"
sonar.ruby.coverage.reportPaths=coverage/.resultset.json
sonar.host.url=https://linktosonar.host
sonar.login=passwordstring

Environment

  • SonarScanner v. 4.4.0.2170
  • Java v. 11.0.6 Oracle Corporation (64-bit)
  • Ruby v. 2.7.1
  • SimpleCov v. 0.19.0
  • SimpleCov-Json v. 0.2.1

Figured it out!

Sonarqube doesn’t work with SimpleCov versions over 0.17.

After downgrading, I was able to get it find the file.