#bug:fault SonarLint refresh Quality Profile issue

  • Version: SonarLint.VSIX-4.8.0.4040-2017
  • We have updated default values for some rules in Quality Profile, updated binding in visual studio 2017 but couldn’t see the updated values.
  • Steps to reproduce:
  1. Bind a Quality profile in Visual studio 2017 [We are using C# code].
  2. Update the profile default value in Sonar Admin mode [We have updated limit for csharpsquid:S3776 rule from 15 to 25].
  3. Update the Quality Profile in visual studio.
  4. Check a function which has sonar issue [We have a function with 20 Cognitive Complexity, which is still shown as sonar error in visual studio with max allowed as 15 which we have already changed in Sonar Quality Profile]
  5. Check the same code in Sonar web site [Function which was shown with sonar error in point 4 is not shown with error in portal. May be here updated profile is used].
  • Potential workaround: We need to see code every-time in Sonar Web portal.

Hi @VikeshMewada, that’s a known limitation of SonarLint for Visual Studio, described in more detail here: https://github.com/SonarSource/sonarlint-visualstudio/issues/176

1 Like

Hello @Val , Thank you for update. Do we have any work around for that? I have tried to uninstall and install SonarLint again with visual studio but no update on rules. :frowning:

The following is not supported, but should work well.

Add an XML file in you solution with name SonarLint.xml and reference it in all of your projects as AdditionalFiles:

  <!-- Put this snippet as a child of the <Project /> element in your csproj files -->
  <ItemGroup>
    <!-- do not forget to set the correct path here, it is csproj-relative -->
    <AdditionalFiles Include="..\SonarLint.xml">
      <Link>Properties\SonarLint.xml</Link> <!-- This is where VS will display the file in the Solution Explorer -->
    </AdditionalFiles>
  </ItemGroup>

Then in this file you could set the properties you want and the rules will be able to pick them up automatically.

Note: The name and the type of the file are important!

The properties are written in special format that is not documented. The easiest way to obtain such file is to execute the begin step of Scanner for MSBuild locally and then copy .sonarqube\conf\cs\SonarLint.xml. The .sonarqube directory should appear in the same directory where you executed the scanner command. You will have to use the same project key as when you connected the solution.

The problem with this approach is that every time you change the properties in SonarQube you will have to manually update the SonarLint.xml.

1 Like

That work perfectly fine, you made my day. Thank you very much for providing a work around.

Looking forward for SonarLint update which will refer Sonar rules and boundary values directly from Quality Profile

Sorry for the late reply. :slightly_smiling_face: