When trying to upload an object-C/Swift project, the sonar scanner returns error with
Line 2 of report refers to a file with an unknown language:
ERROR: Error during SonarQube Scanner execution
Error during parsing of the generic coverage report ‘/mnt/jenkins/workspace/Client_Libs/Fusion/test/build/sonarqube-generic-coverage.xml’. Look at SonarQube documentation to know the expected XML format.
Caused by: java.lang.IllegalStateException: Line 2 of report refers to a file with an unknown language: /mnt/jenkins/workspace/Client_Libs/Fusion/test/ThreeDSSDK/ThreeDSSDK/ios-sdk-core/Models/VCData/SelectButton/NT3DSSelectButtonData.m
SonarQube Scanner 126.96.36.1993
Java 1.8.0_242 Oracle Corporation (64-bit)
Linux 3.10.0-1062.12.1.el7.x86_64 amd64
The result is using appcenter to compile and I have setup a linux box to upload the result using https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage
Welcome to the community!
This is the ticket you’re looking for:
SONAR-12015 - Allow unknown languages in generic test coverage reports
My project is a mixed of obj-C and swift. I am surprise the .m file extension is treated as unknown language.
It’s because you’ve told analysis not to recognize it:
I have tried removing those suffixes but sonarqube would insist of using the build wrapper. we have a strange setup with:
- generate code coverage using MS appcenter
- convert the xcode coverage using https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage
- Execute sonar-scanner with Jenkins worker which is running CentOS7
So it is not possible to run the build wrapper with the current setup
The log showing this:
18:19:21.243 ERROR: Error during SonarQube Scanner execution
The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper
and setting the property “sonar.cfamily.build-wrapper-output”, but it was not specified.
If you don’t want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:
You can’t use SonarQube to only display coverage. There has to be an analysis of the underlying source code as well. In order to make this work, you’re going to need to build with the build wrapper and feed that into analysis.
Is there any known workaround?
Can I ignore Obj-c in coverage report?
OR can I somehow turn Obj-c on for iOS project on SonarCloud?
I have enabled Obj-c using
build-wrapper-macosx-x86: coverage and scanner are now working for both Swift and Obj.
All good now
This is a different question. It deserves a different thread.