RefactoringEssentials
RefactoringEssentials copied to clipboard
Wrong warning RECS0135?
I have this bit of code:
public IEnumerable<double> GetNext()
{
for (double w;;)
{
do
{
_x1 = 2 * _rand.NextDouble() - 1;
_x2 = 2 * _rand.NextDouble() - 1;
w = _x1 * _x1 + _x2 * _x2;
} while (w >= 1);
w = Math.Sqrt(-2 * Math.Log(w) / w);
yield return _x1 * w;
yield return _x2 * w;
}
}
The name of the function has the green squiggles and it's a warning from the Refactoring Essentials telling me that
Method never reaches end or a 'return' statement
I get a similar warning when I transform the function to a property.
While it is true that the method never reaches end, it reaches a return yield
statement—even two. I would assume having endless generators should not be that uncommon.
Is this warning wanted/justified in this case?