Sonar ignoring C/C++ coverage file

I am currently working on publishing code analysis and code coverage to SonarQube Enterprise Edition for C files. The code analysis is being published successfully, however the coverage is showing as 0.0%. There are no errors in the Jenkins console logs, but the coverage report property defined in the pom.xml file appears to be completely ignored.

As the Jenkins build is not yet in a fully functional state, I have placed a hardcoded coverage file optqa_gcda-coverage.info in the project root directory and referenced its path via the SonarQube CFamily report property in pom.xml as follows:

<sonar.cfamily.lcov.reportPaths>${project.basedir}/optqa_gcda-coverage.info</sonar.cfamily.lcov.reportPaths>

However, this also appears to be ignored. According to the SonarQube documentation, several coverage tools are supported for C/C++, each with an associated analysis parameter. I have tried the following parameters, none of which have produced any coverage data:

  • sonar.cfamily.llvm-cov.reportPath

  • sonar.cfamily.gcov.reportsPath

  • sonar.cfamily.cobertura.reportPaths

Could anyone advise on why the coverage data is not being published to the SonarQube server, or suggest any alternative report parameters that should be used for C file coverage?

Hey @nikunjpatel,

sonar.cfamily.lcov.reportPaths is not a supported C/C++ coverage parameter. The supported parameters are the ones you found in the docs, indeed. None of them expects to receive an LCOV .info file, but sonar.cfamily.gcov.reportsPath expects a directory containing .gcov files. If you have an LCOV file, I assume you also have .gcov. Could you try this? Otherwise, you will need to use the parameter appropriate to the coverage tool you’re using.

@andres Yes, you are right. I used cobertura tool and it publish coverage successfully with coverage parameter sonar.cfamily.cobertura.reportPaths. Thanks for pointing this out.