galexandre / sonar-cobertura

Cobertura plugin for SonarQube
GNU General Public License v3.0
30 stars 26 forks source link

Support SonarQube Version 6.4 and higher #16

Closed kasa17 closed 5 years ago

kasa17 commented 6 years ago

In our company we are using SonarQube 6.4 and the latest SonarQube Version is 6.7.1. The SonarQube-Plugin supports only version 6.2. Please, update the Plugin so that is usable for the latest SonarQube Versions.

gliptak commented 6 years ago

On SonarQube 6.4 I see following exception:

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:106)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:89)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:82)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:53)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:99)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: Unable to register extension org.sonar.plugins.cobertura.CoberturaSensor from plugin 'cobertura'
    at org.sonar.core.platform.ComponentContainer.addExtension(ComponentContainer.java:259)
    at org.sonar.scanner.bootstrap.ExtensionInstaller.doInstall(ExtensionInstaller.java:76)
    at org.sonar.scanner.bootstrap.ExtensionInstaller.install(ExtensionInstaller.java:57)
    at org.sonar.scanner.scan.ModuleScanContainer.addExtensions(ModuleScanContainer.java:170)
    at org.sonar.scanner.scan.ModuleScanContainer.doBeforeStart(ModuleScanContainer.java:91)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:259)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:254)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:77)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:49)
    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.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:102)
    ... 9 more
Caused by: java.lang.NoClassDefFoundError: Lorg/sonar/api/scan/filesystem/ModuleFileSystem;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at org.picocontainer.injectors.AdaptingInjection$2.run(AdaptingInjection.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.picocontainer.injectors.AdaptingInjection.injectionFieldAnnotated(AdaptingInjection.java:209)
    at org.picocontainer.injectors.AdaptingInjection.fieldAnnotatedInjectionAdapter(AdaptingInjection.java:188)
    at org.picocontainer.injectors.AdaptingInjection.createComponentAdapter(AdaptingInjection.java:57)
    at org.picocontainer.behaviors.AbstractBehaviorFactory.createComponentAdapter(AbstractBehaviorFactory.java:44)
    at org.picocontainer.behaviors.OptInCaching.createComponentAdapter(OptInCaching.java:45)
    at org.picocontainer.DefaultPicoContainer.addComponent(DefaultPicoContainer.java:536)
    at org.picocontainer.DefaultPicoContainer.access$300(DefaultPicoContainer.java:84)
    at org.picocontainer.DefaultPicoContainer$AsPropertiesPicoContainer.addComponent(DefaultPicoContainer.java:1149)
    at org.sonar.core.platform.ComponentContainer.addExtension(ComponentContainer.java:257)
    ... 33 more
Caused by: java.lang.ClassNotFoundException: org.sonar.api.scan.filesystem.ModuleFileSystem
    at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39)
    at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87)
    at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76)
    ... 47 more
gliptak commented 6 years ago

https://github.com/galexandre/sonar-cobertura/pull/17

galexandre commented 6 years ago

Review in progress.

mitchellmaler commented 6 years ago

What is the status of this? We use Cobertura but are unable to attach them to our SonarQube scan since upgrading to the latest version (7).

galexandre commented 6 years ago

Hi,

Please have a look here: https://github.com/galexandre/sonar-cobertura/tree/6.7-refractor I need to do some extra testing, but the integration and unit tests are good.

mitchellmaler commented 6 years ago

@galexandre Oh nice! I'm excited for the release!

belingueres commented 6 years ago

I just tested 1.9.2-RC on SQ 6.7.2 and it doesn't work (no errors in log but coverage result was 0%.)

galexandre commented 6 years ago

Hi @belingueres

I updated the code, it should work now. Please let me know.

belingueres commented 6 years ago

Hi @galexandre

Tested with branch 6.7-refractor and it worked, with the following warnings:

... [INFO] Sensor CoberturaSensor [cobertura] [INFO] parsing C:\Gabriel\RCyT_v2\RCyT_shared\target\site\cobertura\coverage.xml [WARNING] Coverage measure for metric 'lines_to_cover' should not be saved directly by a Sensor. Plugin should be updated to use SensorContext::newCoverage instead. [WARNING] Coverage measure for metric 'uncovered_lines' should not be saved directly by a Sensor. Plugin should be updated to use SensorContext::newCoverage instead. [WARNING] Coverage measure for metric 'coverage_line_hits_data' should not be saved directly by a Sensor. Plugin should be updated to use SensorContext::newCoverage instead. [WARNING] Coverage measure for metric 'conditions_to_cover' should not be saved directly by a Sensor. Plugin should be updated to use SensorContext::newCoverage instead. [WARNING] Coverage measure for metric 'uncovered_conditions' should not be saved directly by a Sensor. Plugin should be updated to use SensorContext::newCoverage instead. [WARNING] Coverage measure for metric 'conditions_by_line' should not be saved directly by a Sensor. Plugin should be updated to use SensorContext::newCoverage instead. [WARNING] Coverage measure for metric 'covered_conditions_by_line' should not be saved directly by a Sensor. Plugin should be updated to use SensorContext::newCoverage instead. [INFO] Sensor CoberturaSensor [cobertura] (done) | time=385ms ....

Also note that coverage changed from 10.0% (with JaCoCo) to 8.3% (with Cobertura). No source code changes between analisys.

galexandre commented 6 years ago

Hi @belingueres ,

Great news, related to the warning this is related to a class that need to be refactor. However, the open pull request sounds doing the job. I'll try to integrate that to the branch, do a version, some testing and release it.

galexandre commented 6 years ago

Hi guys,

I updated the code on the branch, I found a difference in code coverage values, certainly because of the refactor.

@belingueres, Can you do another test with your code and tell me if your coverage is back to 10%?

belingueres commented 6 years ago

@galexandre updated the code and I get same coverage of 8.3%. (Please note that 10% was as a result of using JaCoCo as coverage library.) No warnings in the command line this time.

galexandre commented 6 years ago

The jar is available.

mitchellmaler commented 6 years ago

Will the be available in the sonarqube marketplace?

galexandre commented 6 years ago

Request open.

https://groups.google.com/forum/#!topic/sonarqube/ICclnhbgolM