# S2583 "Change this condition so that it does not always evaluate to 'false'..." False positive

**URL:** <https://community.sonarsource.com/t/s2583-change-this-condition-so-that-it-does-not-always-evaluate-to-false-false-positive/117194>\
**Category:** Report False-positive / False-negative...\
**Tags:** dotnet\
**Created:** [June 13, 2024, 9:44am UTC](https://community.sonarsource.com/t/s2583-change-this-condition-so-that-it-does-not-always-evaluate-to-false-false-positive/117194 "2024-06-13T09:44:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgbrown](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mgbrown/32/55107_2.png) [@mgbrown](https://community.sonarsource.com/u/mgbrown)\
**Post date:** [June 13, 2024, 9:44am UTC](https://community.sonarsource.com/t/s2583-change-this-condition-so-that-it-does-not-always-evaluate-to-false-false-positive/117194/1 "2024-06-13T09:44:19Z")

</div>

Then tell us:

- What language is this for?

C#

- Which rule?

S2583 Change this condition so that it does not always evaluate to ‘false’; some subsequent code is never executed.

- Why do you believe it’s a false-positive/false-negative?

False positive

- Are you using

- How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)

Sadly I can’t give the actual code due to IP restrictions. But it goes something like this:

```auto
static void DoSomething(string s)
{
    var inWhiteSpace = true;
    var followingWhiteSpace = false; // The variable starts off false
    foreach (var c in s)
    {
        if (char.IsWhiteSpace(c))
        {
            if (inWhiteSpace) // This will be false after the first non white space.
            {
                continue;
            }

            followingWhiteSpace = true; // The variable is set to true
            inWhiteSpace = true;
            continue;
        }

        inWhiteSpace = false;

        if (followingWhiteSpace) // S2583 reported here
        {
             // Do something
             followingWhiteSpace = false;
        }

        // Do something else
    }
}

```

---

<div class="post-metadata">

**Author:** ![Mary](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mary/32/59106_2.png) [@Mary](https://community.sonarsource.com/u/Mary)\
**Post date:** [June 13, 2024, 1:15pm UTC](https://community.sonarsource.com/t/s2583-change-this-condition-so-that-it-does-not-always-evaluate-to-false-false-positive/117194/4 "2024-06-13T13:15:56Z")

</div>

Hello @mgbrown, thank you for reporting this.

I confirm it’s a false positive. However, it has been fixed since the sonar-dotnet analyzer [9.22](https://github.com/SonarSource/sonar-dotnet/releases/tag/9.22.0.87781) (see related issue [here](https://github.com/SonarSource/sonar-dotnet/issues/8264)).  
SonarQube 9.9.4 comes with sonar-dotnet 8.51. You should update to at least SonarQube 10.5.0 to profit from this and more fixes.

Thanks!

---

<div class="post-metadata">

**Author:** ![mgbrown](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mgbrown/32/55107_2.png) [@mgbrown](https://community.sonarsource.com/u/mgbrown)\
**Post date:** [June 14, 2024, 2:28pm UTC](https://community.sonarsource.com/t/s2583-change-this-condition-so-that-it-does-not-always-evaluate-to-false-false-positive/117194/6 "2024-06-14T14:28:23Z")

</div>

> [@Mary](#):
>
> You should update to at least SonarQube 10.5.0 to profit from this and more fixes.

Where as I should be able to, that rather depends upon the people that manage our SonarQube install. I’ll have a chat with them see how far I get.
