Skip to content

Too many chained references - Ignore when using LINQ #15

Description

@jacerhea

I think the inspection for "Too many chained references " should ignore anything in the LINQ namespace.

Activity

  1. citizenmatt commented on Sep 9, 2016

    @citizenmatt
    Collaborator

    Hmm. This is an interesting one, because it might be that you're using a custom SelectMany extension method from another namespace, or even a custom operator, DistinctIgnoringCase or something.

    I wonder if there's a good way to generalise this? Perhaps extend the check for "fluent" interfaces, where it doesn't count methods that return the same type that's passed in, e.g. IEnumerable<T>. It would need to ignore the actual type of T, for things like Select((string s) => s.Length, which would start as IEnumerable<string> and return IEnumerable<int>.

    That would mean the chained LINQ methods are ignored, but if you have too many chained references after standard LINQ, they'd be marked as smelly code.

    How does that sound?

  2. jacerhea commented on Sep 9, 2016

    @jacerhea
    Author

    This may require a few special cases. My suggestion would be to ignore or increase the allowable threshold when

    1. Using extension methods where both the first input argument and return type implement IEnumerable<T>.
    2. Using extension methods where both the first input argument and return type are the same type.
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions