2

I'm trying to use the System.Diagnostics.CodeAnalysis.SuppressMessage attribute to stop sonarqube raising this issue on a specific method in our codebase. I'm not sure exactly what form the suppress message attribute should take. I have tried a few variations on the following with no luck.

[SuppressMessage("csharpsquid", "S1871:Two branches in the same conditional structure should not have exactly the same implementation")]
public static string SomeMethod(string input)

Here is the link to the documentation for the issue: http://dist.sonarsource.com/plugins/csharp/rulesdoc/0.9.0-RC/S1871.html

Using: sonar-csharp-plugin-5.3.2

Petter Hesselberg
  • 5,062
  • 2
  • 24
  • 42
jbutcher
  • 23
  • 1
  • 7

1 Answers1

2

The SonarQube C# plugin version 5.4.0.464 fixes this issue. Have a look at this ticket: https://jira.sonarsource.com/browse/SONARCS-613

Tamas
  • 6,260
  • 19
  • 30
  • 1
    Thanks, updating worked. I still have some doubts as to how exactly this works. Are the Category & CheckId important or does the attribute simply suppress all issues in the marked code? It seems like the category at least isn't important. And the format of the CheckId surprises me, is it parsing out the part before the colon and just using that or does it use the full description? – jbutcher Nov 02 '16 at 15:38
  • 1
    Yes, that's what I noticed too. The category can be empty, for the CheckId, I'm using the ID which shows up in the Error Window. – Tamas Nov 02 '16 at 15:52