How to improve sonar scan time

I am using * Enterprise Edition* Version 9.5 (build 56709) and below are some observations.

  1. My project build time is 3 mins with thread count 16
  2. Running the sonar scan with the same thread count give nullpointer exception.
    mvn -B clean sonar:sonar -T16
  3. Also how i can improve the sonar scan time.

From what I know:

  • Sonar Scanner is single threaded, so fatser CPU is faster scanning time
  • Pull Request scan, to limit the scope to only the changes
  • Probably system disk IO is important as well
  • Define the language for your project, so sonar doesnt have to figure it out and download all the language file rules?
  • Cache the language files from sonar

Thanks @Dennis_DECA

I am trying to enable pull request scan. and my CI is in jenkins with multibranch pipeline. Is there any documentation which can help here.I used below parameters

and when PR is created it scan whole project instead of changes in PR. Any configurations i am missing to make this work?

As far as I know:

  • None of the properties have an impact on this
  • Only important is the projectkey, as per normal scanning
  • If you have the latest sonarscanner, it will detect Jenkins properties automatically and complete them as needed
  • You need to make sure the GIT checkout is complete, deep checkout, so Sonar can detect the differences with history. Not sure how you do this in Jenkins. So avoid shallow checkout or anything similar to this.