Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nunodio opened this issue Sep 26, 2017 · 2 comments

Comments

@nunodio
Copy link

nunodio commented Sep 26, 2017

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
Copy link

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants