I have created a sonar lint incremental scanner. I did this by building on top of the sonarlint-core. This runs as part of our jenkins build on all our branches. .
Goal: Stop new sonarqube issues from getting into out master branch.
Steps:
- Find the files that have changed in git between the branch and the master branch.
- Call the sonarqube server web api for every file that has changed. We do this to get the list of issues on the sonarqube server for the files that have changed
- Run the sonarlint scanner locally on the files that have changed. Get the list of issues
- Compare the issues on the server with the issues found locally. See if any issues have been introduced.
Comment:
Product is great. This increment scanner has been working pretty well. Have had some issues with updating the cache but other then that has been going well.
Questions:
- When do we need to update the "Global Cache"?
- Currently we update this when org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.getState() is not equal to State.UPDATED
- This is a expensive task and takes a long time
- We do this but calling the update method on org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl
- When do we update the "Module" cache/storage?
- We currently do this evey time the incremental scanner is run.
- this is done by the ModuleStorageUpdateExecutor
- We are storing the cache in the user home directory. We also have many jenkins jobs running at the same time on our jenkins build agents/slaves. So the cache could be accessed concurrently. Any suggestions?
- Currently I have a lock that prevents multi incremental scanners running at the same time for a given jenkins build agent/slave. Any suggestions?