I am experiencing multiple false positives with the rule S1172. While the below example is rather convoluted, there are real motivating use cases.
static class Program
{
static void Main()
{
Console.WriteLine(Method(1));
}
private static int Method(int correctValue)
{
int value = 0;
bool Condition()
{
return value < correctValue;
}
while (ConditionChecker(Condition))
{
value++;
}
return value;
}
private static bool ConditionChecker(Func<bool> condition)
{
return condition();
}
}
The latest version of SonarLint incorrectly states that correctValue is unused.
I am using:
- C# 8
- .NET Framework 4.8
- SonarLint 4.28.0.24595
- Visual Studio 16.7.7