SonarLint C# 8.16.0.25740
In the class method Foo:
void Bar() => throw new InvalidOperationException();
public void Foo()
{
string step = "one";
int x = 1;
try
{
Bar();
step = "two";
x = 2;
Bar();
}
catch (Exception)
{
Console.WriteLine($"Failed in step {step} {x}");
}
}
A false positive S1854 occurs on the initialization of βstepβ. Curiously, there is no false positive on the initialization of βxβ.