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

Predicate missedOfTypeOpportunity

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

Import path

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