Skip to content

xccov-to-sonarqube-generic.sh does not account with multiple code branchesΒ #206

@crsantos

Description

@crsantos

Hi,

AFAIK, the xccov-to-sonarqube-generic.sh is not accounting with multiple code branches in the same line, like ternary operators of nil coalescing fallbacks.

e.g.:

Using this snippet we can see that we have 2 different code paths:

testBool(optionalBool ?? false)
  1. optionalBool exists and its value is used
  2. optionalBool is nil and we are coalescing to false

From a random export of xcrun xccov view --archive App.xcresult:
(this is not a match from the snippet above, only an example)

/Users/Random/work/app-ios/Sources/Model.swift:
  ...
  59: 0
  60: 0
  61: 2 [
(1, 9, 0)
]
  62: 2
  63: 2
  64: 8 [
(1, 67, 2)
(91, 0, 2)
]
  65: 2
  66: 2
  67: 4 [
(1, 28, 2)
(97, 0, 2)
]
  68: 2 [
(87, 1, 0)
]
  69: 2
  70: 2 [
(77, 2, 1)
]
  71: 2
  72: 2
  73: *
...

Looking at the conversion script, it only cares about:

 69: 2
 70: 2

But there's extra info on the next line that is important to confirm if we have covered all the possible code branches:

70: 2 [
(77, 2, 1)
]

Questions:

  1. As of today, is that script the official way of reporting Swift code coverage from an xcresult?
  2. If so, shouldn't it support different code branches?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions