Can I use Sonar Qube to show coverage for arbitrary text files?

I am using Enterprise Edition Version 9.9.4 (build 87374)

Basically, I want Sonar Qube to show coverage for text files. I have my own script that produces coverage in generic format. However, Sonar Qube ignores the text files and doesn’t show anything.

My configuration

sonar.sources=./
sonar.inclusions=**/*.yaml
sonar.sourceEncoding=utf-8
sonar.coverageReportPaths=coverage.xml


Related lines in logs:

INFO: Indexing files...
INFO: Project configuration:
INFO:   Included sources: **/*.yaml
INFO: 31 files indexed
INFO: 65 files ignored because of inclusion/exclusion patterns
INFO: 0 files ignored because of scm ignore settings
...
INFO: Parsing /.../coverage.xml
INFO: Imported coverage data for 17 files

My main question is: should this work in principle? I wonder if Sonar Qube ignores my files because they don’t have known source code extensions. Or this should work and problem in my configuration or/and coverage file.

As far as I understand, the answer is - no, you can’t send arbitrary files to SonarQube. It has a list of supported languages and a list of associated file extensions. Unknown files are ignored.
To teach Sonar about a new type of files, you can install a third-party plugin (e.g. https://github.com/sbaudoin/sonar-yaml, but sadly it doesn’t work with the latest version of Sonar), or write your own plugin.

Hey Sergey,

In general, a file needs to be recognized by SonarQube in order to import coverage. There’s a very old ticket to change this, I don’t have a lot of hope we’ll see it implemented. SONAR-12015

However, in the v10.x series of SonarQube, YAML files started to be indexed in order to support the analysis of CloudFormation templates.

In my tests with SonarQube v10.8, this now works with YAML files.

INFO: Sensor Generic Coverage Report
INFO: Parsing /Users/colin/Source/yamltest/coverage.xml
INFO: Imported coverage data for 1 files

However, in the v10.x series of SonarQube, YAML files started to be indexed in order to support the analysis of CloudFormation templates.

Great to hear!

For now, I convert YAML files to JS files with the commented-out content =/
This is the only way I can show the coverage information I need.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.