Idean / sonar-swift

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

SonarException: Can not add the same measure twice - Objective-C and Swift project. #103

Closed nunodio closed 6 years ago

nunodio commented 7 years ago

Hi,

I have an Objective-C and Swift project and the respective Backelite plugins:

sonarqube: 5.6.6 sonar-swift: 0.3.5 sonar-objective-c: 0.6.1

If I comment the line

# sonar.language=swift

in the sonar-project.properties file I got the following error:

ERROR: Error during SonarQube Scanner execution
org.sonar.api.utils.SonarException: Can not add the same measure twice on org.sonar.api.resources.Project@503fbbc6[id=<null>,key=nlife-ios-sonarqube_feature,qualifier=TRK]: org.sonar.api.measures.Measure@74123110[metricKey=tests,metric=Metric[id=<null>,key=tests,description=Number of unit tests,type=INT,direction=-1,domain=Coverage,name=Unit Tests,qualitative=false,userManaged=false,enabled=true,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=false,deleteHistoricalData=false,decimalScale=<null>],value=0.0,data=<null>,description=<null>,alertStatus=<null>,alertText=<null>,date=<null>,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,personId=<null>,persistenceMode=FULL,fromCore=false]
    at org.sonar.batch.sensor.DefaultSensorStorage.saveMeasure(DefaultSensorStorage.java:148)
    at org.sonar.batch.index.DefaultIndex.addMeasure(DefaultIndex.java:173)
    at org.sonar.batch.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:129)
    at org.sonar.plugins.objectivec.tests.SurefireParser.insertZeroWhenNoReports(SurefireParser.java:102)
    at org.sonar.plugins.objectivec.tests.SurefireParser.collect(SurefireParser.java:76)
    at org.sonar.plugins.objectivec.tests.SurefireSensor.collect(SurefireSensor.java:87)
    at org.sonar.plugins.objectivec.tests.SurefireSensor.analyse(SurefireSensor.java:81)
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
    at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
    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:233)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)

If I specify the sonar.language to Swift, the above issue doesn't occur.

Objective-C plugin works correctly in other projects when I only have Objective-C code.

Anyone with the same problem? Any suggestion what it can be?

Thank you.

felazuris commented 7 years ago

Surefire sensor didn't have check for swift language, so swift plugin was trying to add test measure when running objective c project analysis and there was no test run. Created #108 pull request for this.

zippy1978 commented 6 years ago

Hi, PR is merged in release 0.3.8 : https://github.com/Backelite/sonar-swift/releases/tag/0.3.8