Skip to content

NI1017 fails to report errors in certain expressions. #47

Description

@gregr-ni

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();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions