Reputation: 8043
The new version (2.0) of the Resharper plugin for Sonar was extended with the feature of importing an existing Resharper DotSettings file. However, If I set a settings file when I create my quality profile, its settings are not being picked up.
I tried to use the following simple DotSettings file, the only setting in it is disabling the _ prefix of private field names:
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
</wpf:ResourceDictionary>
But even after creating my quality profile with specifying the above DotSettings file, and using this quality profile to analyze a project, I still get the Name 'xyz' does not match rule 'Instance fields (private)'. Suggested name is '_xyz'.
errors.
Also, if I try to download the settings file of my quality profile from the Permalinks tab, it contains a bunch of rules, but it doesn't contain the rule I had in the DotSettings file I imported.
What is the reason for this? Am I doing something wrong?
UPDATE: I looked around a little bit more, but I just got more confused. I've seen that a new version of a runner called "MSBuild SonarQube Runner", but there is also a runner simply called "SonarQube Runner" which we have been using until now.
So the normal SonarQube Runner hasn't been deprecated, but for .NET projects using Resharper, we should start using the MSBuild SonarQube Runner, and that with that we will be able to specify a custom DotSettings file to use when running inspectcode.exe? Or we should manually run inspectcode from the command line?
Upvotes: 2
Views: 2600
Reputation: 3011
All .NET projects should now be analyzed using the MSBuild SonarQube Runner, which was developed jointly with Microsoft and which offers the best experience for .NET users.
As a consequence, the use of the sonar-runner for .NET projects is now deprecated. For COBOL, PL/SQL, and other many other languages (excluding C# and VB.NET), the sonar-runner is still the recommended way to analyze projects.
Since the release of the SonarQube ReSharper version 2.0 plugin, the re-use reports mode is now the preferred one. This means that we expect you to launch inspectcode.exe
and generate a report. Then, set the sonar.resharper.cs.reportPath
property to the path of that report, as well as sonar.resharper.solutionFile
to the path of your solution file, when launching the MSBuild SonarQube Runner.
Here are the steps to analyze a project with R#'s command line inspectcode.exe tool and the MSBuild SonarQube Runner:
[report path]
[solution path]
[SQ Project Key]
/n:[SQ Project Name
/v:[SQ Project Version]
/d:sonar.resharper.cs.reportPath=[report path]
/d:sonar.resharper.solutionFile=[solution path]
It is your responsibility to launch inspectcode.exe with settings that are consistent with the ones set in SonarQube. To make this easy, the SonarQube R# 2.0 plugin allows you to export the rules into a .DotSettings file and provides a permalink to it. Have a look at the plugin's documentation for more info: http://redirect.sonarsource.com/plugins/resharper.html
Now, let's come back to your original problem, which is that the R# .DotSettings import in SonarQube is not working, there are several issues:
/Default/CodeInspection/Highlighting/InspectionSeverities/=
- and all R# rules will remain disabled.Upvotes: 3