SonarLint for VisualStudio 2.1 released, brings consistency with MSBuild, navigation to SonarQube and notifications

Jean-Marc Prieur

<

p>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

<

p>Last Friday, we released SonarLint for Visual Studio 2.1, improving this “connected mode” experience in 3 directions:

<

p>Let’s see these 3 points.

Consistency with the SonarQube Scanner for MSBuild

<

p>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.

<

p>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.

<

p>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.

<

p>clip_image001

<

p>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

clip_image002

  • 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

clip_image003

Notifications in case of quality definition discrepancies

<

p>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.

<

p>This only overrides the ruleset of the project, which itself inherits from the global ruleset in the solution, corresponding to the quality profile.

<

p>clip_image005

<

p>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.

<

p>clip_image006

<

p>Now, in such a case, I get the following warning in Team Explorer:

<

p>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

<

p>clip_image008

<

p>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)

<

p>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)

<

p>clip_image010

<

p>Here is the resulting ruleset for the project after the fixes have been applied:

In closing

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.

0 comments

Discussion is closed.

Feedback usabilla icon