How to speed up sonar scanning on iOS projects

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension):
    SonarQube Enterprise Edition Version 7.9.1 (build 27448);
    SonarQube Scanner 4.2.0.1873-macosx;
  • what are you trying to achieve
    How to reduce the time of Sonar Scanner on iOS projects(Object C)
  • what have you tried so far to achieve this
  1. I have successfully executed SonarQube BuildWrapper and Scanner on the iOS project and generated the report. However, the whole process takes a long time(20+ mins for BuildWrapper and 30+ mins for Scanner). I’d like to ask for help with how to save time.
  2. My current situation is: the Build stage is executed by Xcode plugin of Jenkins so that I have no idea how to merge BuildWrapper in the Build stage(which means I have to run the build process twice: one to generate the ipa file, another for BuildWrapper); I tried to run BuildWrapper along with Unit Test since it was executed by the terminal command, but the scan results of merging BuildWrapper to Build or Unit Test are very different on the same scheme(600+ vs 900+ bugs), can anyone help to figure out why this happened?
  3. I tried to use the parameter “sonar.cfamily.threads” in SonarQube scanner, which saved some time, but the left time still couldn’t be accepted. Are there other ways to speed up the process?
    Thanks a lot for your help!

Hi @taoy,

please make sure you install the latest version of the SonarCFamily plugin and use its latest version of build-wrapper, which is currently 6.6.

Why are you surprised by this? Isn’t it already your build time?

How much time do you get with how many threads?

In the latest version of SonarCFamily analyzer we support Incremental Analysis, see the related section in this post: C++ developers now benefit from more efficient analysis and deeper Core Guidelines coverage. I would invite you to test it.

Hi Massimo,
Thanks a lot for your reply!
I’m using build-wrapper of the version 6.3, I will upgrade it and try again.
I know that the time of BuildWrapper is actually the build time. I’m suffering that I need to run the build process twice now because of build-wrapper can’t be combined with the Xcode plugin of Jenkins.
I tried to set “sonar.cfamily.threads=2” on my local Mac Pro, which has 2 cores. It decreased the time of SonarQube Scanner from 56 mins to 36 mins.
It’s amazing that Incremental Analysis has been supported! Thanks for your shared post and how shall I test it?

Hi @taoy,

You could replace the Xcode plugin for Jenkins by manually invoking build-wrapper + Xcode build, that way you can simplify the chain.

Upgrade to the latest version of SonarCFamily 6.6, update the build-wrapper and follow the documentation, see Incremental Analysis section in C++ developers now benefit from more efficient analysis and deeper Core Guidelines coverage.

Thanks a lot, Massimo! I will try it. :grinning:

1 Like