Idean / sonar-swift

Open source Swift plugin for SonarQube (also supports Objective-C)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Metric 'test_data' should not be computed by a Sensor

giacgbj opened this issue · comments

Since SonarQube 6.2, the following blocking error occurs:

[11:16:10]: ▸ ERROR: Error during SonarQube Scanner execution
[11:16:10]: ▸ org.sonar.api.utils.XmlParserException: Cannot parse surefire reports
[11:16:10]: ▸ at org.sonar.plugins.swift.tests.SwiftSurefireParser.parseFiles(SwiftSurefireParser.java:142)
[11:16:10]: ▸ at org.sonar.plugins.swift.tests.SwiftSurefireParser.collect(SwiftSurefireParser.java:74)
[11:16:10]: ▸ at org.sonar.plugins.swift.tests.SwiftSurefireSensor.collect(SwiftSurefireSensor.java:87)
[11:16:10]: ▸ at org.sonar.plugins.swift.tests.SwiftSurefireSensor.analyse(SwiftSurefireSensor.java:81)
[11:16:10]: ▸ at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
[11:16:10]: ▸ at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
[11:16:10]: ▸ at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
[11:16:10]: ▸ at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:182)
[11:16:10]: ▸ at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
[11:16:10]: ▸ at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
[11:16:10]: ▸ at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:247)
[11:16:10]: ▸ at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:242)
[11:16:10]: ▸ at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:232)
[11:16:10]: ▸ at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
[11:16:10]: ▸ at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
[11:16:10]: ▸ at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
[11:16:10]: ▸ at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
[11:16:10]: ▸ at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
[11:16:10]: ▸ at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
[11:16:10]: ▸ at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)
[11:16:10]: ▸ at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:116)
[11:16:10]: ▸ at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)
[11:16:10]: ▸ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[11:16:10]: ▸ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[11:16:10]: ▸ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[11:16:10]: ▸ at java.lang.reflect.Method.invoke(Method.java:498)
[11:16:10]: ▸ at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
[11:16:10]: ▸ at com.sun.proxy.$Proxy0.execute(Unknown Source)
[11:16:10]: ▸ at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
[11:16:10]: ▸ at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
[11:16:10]: ▸ at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)
[11:16:10]: ▸ at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
[11:16:10]: ▸ at org.sonarsource.scanner.cli.Main.main(Main.java:61)
[11:16:10]: ▸ Caused by: java.lang.UnsupportedOperationException: Metric 'test_data' should not be computed by a Sensor
[11:16:10]: ▸ at org.sonar.scanner.sensor.DefaultSensorStorage.saveMeasure(DefaultSensorStorage.java:240)
[11:16:10]: ▸ at org.sonar.scanner.index.DefaultIndex.addMeasure(DefaultIndex.java:231)
[11:16:10]: ▸ at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:131)
[11:16:10]: ▸ at org.sonar.plugins.swift.tests.SwiftSurefireParser.saveTestsDetails(SwiftSurefireParser.java:167)
[11:16:10]: ▸ at org.sonar.plugins.swift.tests.SwiftSurefireParser.parseFiles(SwiftSurefireParser.java:135)
[11:16:10]: ▸ ... 32 more

I face exactly the same issue, @giacgbj did you some kind of workaround ?

@jkernech I don't think you can avoid it. The code must be changed.
Considering the names of the classes involved, you can try not to generate test reports in order to avoid, at least, that exception.

@giacgbj Thanks for you feedback, I will check this out

@giacgbj @jkernech : a quick fix is to comment out the following line:

org.sonar.plugins.swift.tests.SwiftSurefireParser; Line 167:

context.saveMeasure(resource, new Measure(CoreMetrics.TEST_DATA, testCaseDetails.toString()));

with this fix, script shows me "Done linting! Found 600 violations, 87 serious in 57 files." but in SonarQube I see only 2

Running into the same issue. It appears that CoreMetrics.TEST_DATA is deprecated;
Same for MutableTestPlan mentioned.

Running into same issue, anybody know when this will be resolved? Is there something we can disable in our sonar-project.properties file so that we can skip this step and it doesn't break our Jenkins pipeline?

Hi,

The problem is due to API deprecation since SonarQube 6.2.

I will fix it as soon as I'm back from holidays.

Hi all !

Issue is fixed in release 0.3.2

Enjoy !