-
Notifications
You must be signed in to change notification settings - Fork 276
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
Mixed ObjC and Swift Project - Can not add the same measure twice on org.sonar.api.resources.Project #50
Comments
Hello. This may indeed happen for several reasons.
|
Thanks for the response. I have done #2, and actually that is the reason it fails. If I specify a language, then it seems to work ok for that language. |
For #1, I meant I have a project here with both Swift and Objective-C, for which I did not specify the language and it passes through the plugin. If it doesn't work for you when specifying the |
Just for some more info: the complete error messages is: Could this be because our mixed project does not have any unit tests at all? It seems like the duplicate measure is related to tests. We are using both backelite Objc & Swift scanners. |
Hi @leddo, Can not add the same measure twice usually happens when the same source file is scanned twice (it tries to record the same mesure for the same file twice). It is often caused by unit tests files being in the sonar.sources dirs : test files must be separated (in a different path) from the app source code. Gilles |
Hey, we also encountered this issue and we have been able to hunt it down to the following:
They create following JUNIT report:
For me it is interesting if this is a sonarQube issue or if it is the Plugin? |
Yeah this is still a problem for me. I have a mixed objc-swift project. Only way I can get it to work, is by setting a language property in sonar-project.properties. I have a handful of unit tests, all written in swift, but in the sonar debug output, is see messages like I think the coverage file is being processed twice - once for objective-c scanner, and once for the swift scanner. Any help, or example properties files from people with working systems that have mixed code base, and unit tests and coverage and linting actually working? |
That would be very helpful for us too |
Hi, I have the same problem. @leddo , you'r right, its the coverage file which processed twice. In SwiftCobertunaSensor.java (sonar-swift) and CobertunaSensor.java (sonar-objc) have the same pattern : DEFAULT_REPORT_PATTERN = "sonar-reports/coverage-*.xml"; I have tested with pattern sonar-reports/coverage-objc*.xml for objc and sonar-reports/coverage-swift*.xml for swift plugin, and adjust run-sonar-swift.sh for export coverage into sonar-reports/coverage-swift.xml. It works. I will make two Pull Request today (one for objc, and one for swift). |
Hi, |
Hi, with the 2 fixes, I still have the same error (but not on the same file):
In the code: I've made a quick fix in org.sonar.plugins.swift.tests.SwiftSurefireParser.getReports :
Maybe it's not perfect, but it works for me. |
I am getting an error when trying to run a project through it that has both swift and objective-c files in it.
16:40:59 ERROR: Error during Sonar runner execution
16:40:59 org.sonar.runner.impl.RunnerException: Unable to execute Sonar
16:40:59 at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
16:40:59 at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
16:40:59 at java.security.AccessController.doPrivileged(Native Method)
16:40:59 at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
16:40:59 at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
16:40:59 at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
16:40:59 at org.sonar.runner.api.Runner.execute(Runner.java:100)
16:40:59 at org.sonar.runner.Main.executeTask(Main.java:70)
16:40:59 at org.sonar.runner.Main.execute(Main.java:59)
16:40:59 at org.sonar.runner.Main.main(Main.java:53)
16:40:59 Caused by: org.sonar.api.utils.SonarException: Can not add the same measure twice on org.sonar.api.resources.Project@278cbf5a[id=,key=com.blahblahblah:Mobile-iOS-blah,qualifier=TRK]: org.sonar.api.measures.Measure@7bd0e2e9[metricKey=tests,metric=Metric[id=,key=tests,description=Number of unit tests,type=INT,direction=-1,domain=Coverage,name=Unit tests,qualitative=false,userManaged=false,enabled=true,worstValue=,bestValue=,optimizedBestValue=false,hidden=false,deleteHistoricalData=false,decimalScale=],value=0.0,data=,description=,alertStatus=,alertText=,date=,variation1=,variation2=,variation3=,variation4=,variation5=,url=,personId=,persistenceMode=FULL,fromCore=false]
If I add sonar.language=objc to the sonar-project.properties file, then it all works (the app is predominantly ObjC. but with that removed (the comment in the default properties file says to remove it for a mixed app), then the error happens above.
Also, this project has no unit tests in it, so could that be contributing to the problem?
Any ideas ?
The text was updated successfully, but these errors were encountered: