The code below should report an NI1017 error but does not because it is in the last section of a ternary operator. Errors in the first value of ternarys are reported correctly.
private static IEnumerable Ternary(IEnumerable numbers)
{
return numbers is null
? Enumerable.Empty()
: numbers.Where(n => n < 10).Select(n => $"{n}");
}
Likewise violations in a return statement are not reported. If you assign to a local then return the local, the error is reported.
private static int Expression(IEnumerable numbers)
{
return numbers.Where(n => n < 10).Select(n => n * 2).Max();
}