Skip to content

Commit

Permalink
S2589: Add FP repro for #8449 (#8453)
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource authored Dec 8, 2023
1 parent 25f99fe commit 0055b88
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3458,10 +3458,28 @@ private void Test()
Console.WriteLine();
}
}

public class Repro_8445_OtherClass
{
public static readonly int readonlyStaticInt = 42;
public static readonly string readonlyStaticString = "42";
public readonly int readonlyInt = 42;
public readonly string readonlyString = "42";
}

// Reproducer for https://github.com/SonarSource/sonar-dotnet/issues/8449
public class Repro_8449
{
public static void Foo()
{
int delay = 100;
while (true)
{
if (delay < 1000) // Noncompliant {{Change this condition so that it does not always evaluate to 'True'.}} FP
// ^^^^^^^^^^^^
{
delay = delay * 2;
}
}
}
}

0 comments on commit 0055b88

Please sign in to comment.