A few weeks ago, we released SonarLint for Visual Studio 2.0 and you discovered the SonarQube connected mode enabling customers to align the definition of the quality of a Visual Studio solution with a quality profile in SonarQube
Last Friday, we released SonarLint for Visual Studio 2.1, improving this “connected mode” experience in 3 directions:
- Consistency with the SonarQube Scanner for MSBuild
- Navigation to SonarQube
- Notifications in case of mis-alignments between the definition of the quality in the IDE, and the one in SonarQube
Let’s see these 3 points.
Consistency with the SonarQube Scanner for MSBuild
We wanted to make sure that users get the same results in the IDE as they get during a continuous integration build. This has not been the case so far, because Roslyn analyzers were provisioned and configured for every MSBuild project, even for test projects and for projects explicitly excluded from the analysis.
Now, when we bind a solution to SonarQube using the bind command, no Roslyn analyzer NuGet packages are provisioned for test projects, or for projects excluded from the build.
There are still a few differences, though (the IDE doesn’t support file-level exclusions, and the logic used to detect generated code isn’t exactly the same). We’ll improve them with time.
Navigation to SonarQube
It is now possible to navigate to SonarQube directly from the Team Explorer.
- Right-clicking on a SonarQube project and choosing the View in SonarQube command opens a browser where you will see the dashboard for the SonarQube project directly
- You can also right-click on the tree nodes corresponding to the SonarQube server and choose Browse, which will open a browser on the portal itself
Notifications in case of quality definition discrepancies
Once your solution has been bound to a SonarQube quality profile, nothing prevents you from changing the rulesets on a given project if you wish. For example, in the example below, I’ve deactivated rule S1006 and activated rule S100.
This only overrides the ruleset of the project, which itself inherits from the global ruleset in the solution, corresponding to the quality profile.
In the previous version, when I went to the Team Explorer SonarQube tab, right clicked on a project and selected Update (which used to be named Sync, BTW) to update my local definition of quality from SonarQube’s quality profile, the local rulesets were not touched, and therefore you could have a definition of the quality lower than the one defined in SonarQube.
Now, in such a case, I get the following warning in Team Explorer:
The applied ruleset is weakening the SonarQube quality profile in one or more projects. See output window (General) for more details. Click here to fix automatically
I’m now warned about the rules that are less strict. (it’s fine to have a stronger definition as you may wish to hold to a higher bar for your own work)
If I want, I can let SonarLint for Visual studio fix this mis-alignment by clicking the Click here link in the Team Explorer SonarQube’s task. It will only touch the rules in the projects rulesets, which are weaker (here S1006). The stronger ones will be left unchanged (S100 is not mentioned)
Here is the resulting ruleset for the project after the fixes have been applied:
We look forward to hearing from you. Please send us your feedback by asking some questions on StackOverflow or directly by reporting any bugs you find on the SonarQube Google Group. You can also submit suggestions for new features, for example, on User Voice.