Open
Description
Rule S2971 seems like multiple rules folded into one. It would be better to split the rule into multiple ones and re-evaluate.
This way users can enable and disable the parts that are useful to their codebase.
Potential split:
- Use
OfType
instead of usingSelect
with as to typecast elements and then null-checking in a query expression to choose elements based on type. - Use
OfType
instead of usingWhere
and the is operator, followed by a cast in aSelect
- Use an expression in
Any
instead ofWhere(element => [expression]).Any()
. - Use
Count
instead ofCount()
when it’s available. - Don’t call
ToArray()
orToList()
in the middle of a query chain.
Activity