SonarQube Server Data Center Edition v2025.1.1
SonarScanner for MSBuild 10.1.2
Scanner is run by a Jenkins agent on a Windows Server
Plugin csharpenterprise, version 10.4.1.110446
My goal is to reduce SQ scanning time during pull requests on a repo with 10k+ files. There is a concept of Incremental Pull Request analysis which should work for C# as stated in the documentation:
This is what I have tried:
1. Run a scan for the master branch to build the analysis cache
The logs are from processing the small (~100 files) repository. Problem is analogous to the repo with 10k+ files.
Excerpts from log file:
Processing analysis cache
Incremental PR analysis: Base branch parameter was not provided.
Cache data is empty. A full analysis will be performed.
MSBuild version 17.11.2+c078802d4 for .NET Framework
c:\workspace\repo\project\aaa.cs(372,17): warning S125: Remove this commented out code. (https://rules.sonarsource.com/csharp/RSPEC-125) [c:\workspace\repo\project\project-file.csproj]
Dumping content of sonar-project.properties
-------------------------------------------
B05329E8-C28B-48E8-1234-ADF5154BB417.sonar.sources=\
"c:\\workspace\\repo\\project\\aaa.cs",\
Calling the SonarScanner CLI...
INFO: Analyzing on SonarQube server 2025.1.1.104738
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Indexing files of module 'project'
DEBUG: 'project/aaa.cs' generated metadata with charset 'UTF-8'
DEBUG: 'project/aaa.cs' indexed with language 'cs'
DEBUG: Processing Roslyn report:
DEBUG: Adding normal issue S125: C:\workspace\repo\project\aaa.cs
DEBUG: Detection of duplications for C:/workspace/repo/project/aaa.cs
INFO: Sensor C# File Caching Sensor [csharpenterprise]
DEBUG: Incremental PR analysis: Preparing to upload file hashes.
DEBUG: Incremental PR analysis: Adding hash for '/C:/workspace/repo/project/aaa.cs' to the cache.
DEBUG: Incremental PR analysis: Adding hash for '/C:/workspace/repo/project/only-file-that-will-be-changed-in-pull-request.cs' to the cache.
2. Run a scan for the PR branch to potentially use the analysis cache
Pull request has changes in one file: C:\workspace\repo\project\only-file-that-will-be-changed-in-pull-request.cs.cs
Cache is downloaded:
Processing analysis cache
Downloading cache. Project key: project-key, branch: master.
Downloading from https://sonarqube-server-address/api/analysis_cache/get?project=project-key&branch=master...
Response received from https://sonarqube-server-address/api/analysis_cache/get?project=project-key&branch=master...
But gets zero hits:
Incremental PR analysis: 0 files out of 68 are unchanged.
I this PR I would expect reduced scanning time and message “Incremental PR analysis: 67 files out of 68 are unchanged” (if I understand this properly).
What can be noticed is that in the downloaded cache file paths have forward slashes (/C:/workspace/repo/project/aaa.cs) whereas in most cases in the log file backslashes are used (it is not consistent in the log file).
What am I missing here?
Maybe the Sonar scanner has a bug and can’t handle these paths?
Or maybe is it a file encoding problem?
I would appreciate any help.