Generic code coverage report refers to a file with an unknown language

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 4.2.0.1873
Java 1.8.0_242 Oracle Corporation (64-bit)
Linux 3.10.0-1062.12.1.el7.x86_64 amd64

sonar properties:
-Dsonar.projectKey=sdks:fusion-sdk-ios
-Dsonar.sources=.
-Dsonar.host.url=https://sonarqube7.intra.nudatasecurity.com
-Dsonar.login=**
-Dsonar.coverageReportPaths=build/sonarqube-generic-coverage.xml -Dsonar.swift.coverage.reportPath=Coverage.report
-Dsonar.cfamily.build-wrapper-output.bypass=true
-Dsonar.c.file.suffixes=-
-Dsonar.cpp.file.suffixes=-
-Dsonar.objc.file.suffixes=-

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

Hi,

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.

Hi,

It’s because you’ve told analysis not to recognize it:

 
HTH,
Ann

I have tried removing those suffixes but sonarqube would insist of using the build wrapper. we have a strange setup with:

  1. generate code coverage using MS appcenter
  2. convert the xcode coverage using https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage
  3. 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
java.lang.UnsupportedOperationException:

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:

sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

Hi,

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.

 
Ann

Hi @ganncamp

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?

UPD

I have enabled Obj-c using build-wrapper-macosx-x86: coverage and scanner are now working for both Swift and Obj.
All good now :smiley:

Thanks!

Hi @vladimir_abr,

This is a different question. It deserves a different thread.

 
Ann