Swift | xccov-to-sonarqube-generic.sh does not handle branch coverage

:information_source: I’m not sure who owns this repo, but it contains the only way I have found to convert Xcode’s code coverage into a generic Sonarqube format (please advise if there’s a better way).


I would like to discuss something that can be improved in this specific script.

I opened an issue explaining what I found, while converting an .xcresult’s generated from from Xcode.

This script is analyzing if the line had a hit or not, but completely ignores branch coverage, for other code branches in the same line, like ternary operators, or nil coalescing fallbacks.

I’m not sure if this was on purpose, but I guess that Sonarqube supports this, I can see on the official docs an image with the red/white striped pattern:

Also, I can see that this is supported by the xsd definition.

My question is:

  • Shouldn’t this script support branch coverage?
  • If so, and if Sonar owns the repo, can we expect the script to be updated?

It should require a refactor, because it needs to analyze multiple lines of the output, but it’s not very complex.

Thanks in advance.

Details

Hey @carlos-santos

  • Yes, we (Sonar) own this repo
  • It’s an example that lots of customers are using
  • SonarQube’s generic coverage format supports branch coverage, so if the source data (xccov) has that data, like you said it’s simply a matter of updating the script

It’s not really on our radar. But it’s open source, and we accept PRs. :slight_smile: