We have the following code in our system. It is not very pretty, but the rule is a false positive. This condition is not always true. It is possible for the “counter” to be 10.
We are using c#
We ask that users don’t share screenshots of code, can you please share a self-contained snippet of code? And other details, like what language you’re analyzing.
You can find what information makes a great false-positive report here:
This looks similar to a known issue that has been reported here – which you can follow along on.
As noted in the ticket:
Apologies for the inconvenience. For the time being, waiting for the issue to be fixed:
If you are using SonarQube: you can mark the issue as a false-positive in the UI. The rule can also be disabled in your Quality Profile if it’s particularly noisy.
You can use #pragma warning disable and #pragma warning restore to locally disable the rule in the source