CodeQL library for C#
codeql/csharp-all 3.0.1-dev (changelog, source)
Search

Predicate missedOfTypeOpportunity

Holds if foreach statement fes can be converted to an .OfType() call. That is, the loop variable is accessed only in the first statement of the block, the access is a cast with the as operator, and the first statement is a local variable declaration statement s.

Import path

import Linq.Helpers
predicate missedOfTypeOpportunity(ForeachStmtEnumerable fes, LocalVariableDeclStmt s)