Get warnings in the IDE before pushing to the server

We have several .NET 6 projects which have the sonar roslyn analyser installed, so we do get some SonarQube warnings locally.

But for some reason once we push to the server and CI is running with SonarQube, we get a lot of warnings that we did not get when building locally.

Is there a reliable workflow we could establish to see all or almost all of SonarQube warnings locally in the IDE (Rider, Visual Studio) before actually committing and pushing the changes to the CI server?

It is a very tedious workflow to see the problems only after pushing, when you think you’re done only to see there are more issues and then having to amend and force push (if allowed allowed at all!) additional fixes. Having to manually navigate to the places with the additional issues makes it even worse.


Welcome to the community!

There are some rules we deliberately don’t run in SonarLint, mainly to avoid negatively impacting the development experience.


None of the rules that that SonsrQube complains about only on the server fall into the categories mention in the list you linked, but still I don’t get the warnings locally, e.g. S1135 for TODO comment.

I‘d argue that the developer experience is affected very negatively if there are rules that I can only see when it is already to late or when I have to do several wait-for-ci-build-find-the-problematic-code-fix-and-amend-force-push-loops to get my code right.

It would be cool that there is at least an option to run the rules locally. Let me decide.

SonarLint will run those rules locally.

For C#/VB rules in Visual Studio, it’s VS that decides when to trigger analysis and for which files. You can use the normal VS options to control the scope of analysis and filtering in the Error List.

For Rider, SonarLint will show issues in the current file. There is also a batch mode, which you can use to detect issues in the entire solution.

You are also in control of which rules are executed. If you are using Connected Mode, SonarLint will generate and use a ruleset that matches the Quality Profile on the SonarQube/SonarCloud server. If you are using Standalone mode, you can use ruleset/editorconfig files as normal.