Idean / sonar-swift

Open source Swift plugin for SonarQube (also supports Objective-C)
Other
897 stars 276 forks source link

NullPointerException while processing Junit Surefire report #275

Open pietrobasso opened 4 years ago

pietrobasso commented 4 years ago

New Issue Checklist

Issue Description

Inside my sonar-project.properties I correctly specified sonar.swift.surefire.junit.reportsPath=reports/ as my junit reports path. I have a valid TEST-report.xml file (checked with an online html parser and it works). If I try to run sonar through fastlane, I get the following error:

INFO: Sensor Surefire [backelitesonarswiftplugin]
INFO: Processing Surefire report TEST-report.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 15.690s
INFO: Final Memory: 13M/54M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.NullPointerException
    at java.base/java.text.DecimalFormat.parse(DecimalFormat.java:2139)
    at java.base/java.text.NumberFormat.parse(NumberFormat.java:432)
    at org.sonar.api.utils.ParsingUtils.parseNumber(ParsingUtils.java:47)
    at com.backelite.sonarqube.commons.surefire.SurefireStaxHandler.getTimeAttributeInMS(SurefireStaxHandler.java:125)
    at com.backelite.sonarqube.commons.surefire.SurefireStaxHandler.parseTestResult(SurefireStaxHandler.java:115)
    at com.backelite.sonarqube.commons.surefire.SurefireStaxHandler.parseTestCase(SurefireStaxHandler.java:75)
    at com.backelite.sonarqube.commons.surefire.SurefireStaxHandler.parseTestCase(SurefireStaxHandler.java:58)
    at com.backelite.sonarqube.commons.surefire.SurefireStaxHandler.stream(SurefireStaxHandler.java:48)
    at com.backelite.sonarqube.commons.surefire.StaxParser.parse(StaxParser.java:55)
    at com.backelite.sonarqube.commons.surefire.StaxParser.parse(StaxParser.java:47)
    at com.backelite.sonarqube.commons.surefire.SurefireReportParser.parseFiles(SurefireReportParser.java:92)
    at com.backelite.sonarqube.commons.surefire.SurefireReportParser.parseFiles(SurefireReportParser.java:84)
    at com.backelite.sonarqube.commons.surefire.SurefireReportParser.collect(SurefireReportParser.java:78)
    at com.backelite.sonarqube.commons.surefire.SurefireSensor.execute(SurefireSensor.java:73)
    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:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:388)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:384)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:353)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
    at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
    at org.sonar.batch.bootstrap
per.Batch.execute(Batch.java:66)
    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:564)
    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)
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

My guess is that SurefireReportParser is failing for some reason here: https://github.com/Idean/sonar-swift/blob/a5e219515cd39701aa5c8d93f954a64acff3aa82/commons/src/main/java/com/backelite/sonarqube/commons/surefire/SurefireReportParser.java#L82

Command executed

bundle exec fastlane *name of my sonarqube lane*

Environment

sonar-swift 0.4.6 sonarqube 8.4.1.35646 sonar-scanner 4.3.0.2102

pietrobasso commented 4 years ago

This seems related to https://github.com/Idean/sonar-swift/issues/255, no one replied on that though.