Change this condition so that it does not always evaluate to ‘false’. If a boolean expression doesn’t change the evaluation of the condition, then it is entirely unnecessary, and can be removed. If it is gratuitous because it does not match the programmer’s intent, then it’s a bug and the expression should be fixed.
It marks the string.IsNullOrEmpty((string)token) part with a red squiggly line, so I am assuming it’s here it complains mainly.
Either I am not understanding fully what Sonar sees as redundant, or this is a bug. My only guess is that it’s the cast from JToken to string that makes it confused, while this is something we often do in C# for this kind of data.
What version of SonarCsharp are you using? What version of SonarQube are you using?
I’ve tried to reproduce with the latest version of our analyzer and I could not. Probably this got fixed in the 7.16 version when we fixed lots of false positives
You are talking about the Sonar Scanner for MSBuild, which only orchestrates the analysis
The scanner downloads the plugin (which is used to analyze the code) from your SonarQube instance. You can check the latest version for the C# plugin https://docs.sonarqube.org/latest/analysis/languages/csharp/ - you will need to update it on your SonarQube instance
Sorry that I have taken a long time to get back to you on this.
We have migrated from a local - per project - deployment of SonarQube (pilot) to running on a company enterprise server.
This problem still appears for us with SonarCSharp v8.6.1, SQ 7.9.2 (LTS). We are not using SonarLint at this point.
I tried to reproduce it with SonarCSharp 8.6.1, but it didn’t reproduce. I’m only able to reproduce it with version 7.15. It doesn’t reproduce in 7.16 so it was fixed there and Andrei mentioned.