ERROR: String is not parsed on SonarQube 9.7.1

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube Developer Edition Version 9.7.1 (build 62043)
    Unknown Swift version as we can’t find any information about it in our instance.

  • what are you trying to achieve

Wer are trying to analyse a Swift source code, it’s partially working and only 6 files are being analysed on a +1000 files project.

We have a piece of code that looks like this:

@objc
private func notify() {
  DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) { [weak self] in
    guard let self: FooViewController = self else {
      return
    }
    //...
  }
}

SonarQube stops when it attempts to analyse self, putting an arrow (^) at the f from the first self.

  • what have you tried so far to achieve this

We tried to update the Swift plugin but it seems to not be installed? It seems to be a embeed tool on SonarQube developer edition. The project uses Swift 5.1 (guard let self = self else {} seems to be supported since swift 4.2).
As addition, the project compiles just fine on Xcode 13.x.

Hi @ppamorim, thanks for bringing this to our attention. I can reproduce the parsing problem. However, we need more details to understand better why the analyzer processes only 6 files. Could you send us the complete analysis logs, please?

Hi francois.mora, thank you for the answer.

Here is the full log: gist:2f2f853c005d1dd27aacd0ca1831b393 · GitHub

I redacted some sensitive information from it.

We build our report on a Mac Mini in our in house server, then we process the xcresult using your xccov-to-sonarqube-generic.sh script to your expected format, then we upload the result to a Github hosted Linux instance and run your uploader sonarsource/sonarqube-scan-action@master.

I hope that’s clear.

(Offtopic: I can’t mention you as I am a new user)

Hi @ppamorim, we have fixed this parsing error and released a new version of the analyzer that will come with the next release of SonarQube.
Thanks for your help

2 Likes