Removing the if will make this work as expected.
The block before try should already be connected to catch block. It's not clear why it produces a FP
public int ReadAfterCatchAll_WithType(bool condition)
{
var value = 100; // Noncompliant FP, used after catch all
try
{
CanThrow();
if (condition)
{
CanThrow();
}
value = 200;
}
catch (Exception exc)
{
}
return value;
}
This likely has the same root cause as
public void ReadInCatch_WithBranching(bool condition)
{
var value = 100; // Noncompliant FP, used in catch
try
{
value = CanThrow();
if (condition)
{
CanThrow();
}
else
{
CanThrow();
}
}
catch
{
Log(value);
}
}
Removing the
if
will make this work as expected. The block before try should already be connected tocatch
block. It's not clear why it produces a FPThis likely has the same root cause as