We’ve recently set up SonarCloud scanning for our NX monorepo and are noticing a difference between the scan results in our Bitbucket pipeline compared to running the scanner locally and uploading the results.
This difference is mainly noticeable in the detection of types in our Typescript codebase. The locally run sonarqube-scanner correctly has type information available and marks errors based on that type information, while the scanner in the Bitbucket pipeline incorrectly marks certain code as an error because it does not have the type information. The biggest marker of the issue is rule typescript:S3735, where it does not know that the ‘void-ed’ function returns a Promise.
The local run shows 108 fixed issues and a clear sudden drop in the amount of issues in the graph, indicating that the result is different. (ignore the coverage difference, not all tests had been executed for the coverage upload)
All the configuration is stored in our sonar-project.properties file, besides the SonarCloud token. So the scanners have identical input.
How can there be a difference between the scanning result of sonarqube-scanner and sonarsource/sonarcloud-scan ? And how can we resolve this?
The node_modules folder from the install step is saved in our node cache, but we never gave Sonar access to that cache. So it didn’t have the dependencies “installed”.