Scanner SonarScanner for MSBuild 4.6 (Using the .NET Core version of the Scanner for MSBuild)
Hi,
We have been use SonarQube for a while. And until this time there was no problem with scanning.
Now we have a problem with a project. This project size is about 60k. This project have been scanned with no problem until now. When we want to scan the same project, scan time is getting longer(over 30~45 minutes) and scanning does not end.
There are another project with same size and have a lots of bug, but it’s scanning time is not’t so long as this project. It takes only about 4~5 minutes.
I don’t know what is the problem. There is nothing in the log to fing the issue. I scan the project with 2 rule, time is running out.
What exactly changed? Did this happen after updating SonarQube to a newer version? I understand from you that at Time A, you were scanning this project with no problems and at Time B this performance issue occurred. What happened between Time A and Time B?
What do you mean you scan the project with 2 rule?
To debug, we really need the verbose logs of the build and the scan to understand what’s happening.
to enable verbose logging for the scan, add /d:sonar.verbose=true (e.g. SonarScanner.MSBuild.exe begin /k:"MyProject" /d:sonar.verbose=true) to the BEGIN step and then share with us the logs from the END step
to get verbose analyzers diagnostics from the BUILD step, please add /p:reportanalyzer=true and /v:d (e.g. msbuild /p:reportanalyzer=true /v:d) and share with us the build logs
If sharing the build logs is not an option, we need the time taken by each analyzer (i.e. rule)
Total analyzer execution time: 893.913 seconds.
NOTE: Elapsed time may be less than analyzer execution time because analyzers can run concurrently.
Time (s) % Analyzer
893.913 100 SonarAnalyzer.CSharp, Version=7.13.0.0, Culture=neutral, PublicKeyToken=c5b62af9de6d7244
448.313 50 SonarAnalyzer.Rules.CSharp.TokenTypeAnalyzer
445.228 49 SonarAnalyzer.Rules.CSharp.SymbolReferenceAnalyzer
.....
Actually, there is no change with SonarQube, no upgrade, no new thing. Changes are related to new codes. The project grows with new codes.
I enabled this property.
And these features as well. Now there are too many logs in which I get lost
The solution contains several .csproj. I guess it takes a long time while scanning some projects.
I will share with you some screen shot.
If you have many projects, it’s worth verifying each. You gave 2 screenshots: one with a project that takes 3 minutes to analyze, and another with a project that takes 13 minutes - that’s a big difference. Most of the time is probably spent on analyzing a small set of projects, and you should look into what takes time inside those analyses.
From what I see S1144 - UnusedPrivateMember is taking a longer time that the rest. You can try and disable this rule from the quality profile and see the overall impact.