mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
22 lines
659 B
Plaintext
22 lines
659 B
Plaintext
/**
|
|
* @name Missed opportunity to use Where
|
|
* @description The intent of a foreach loop that implicitly filters its target sequence can often be better expressed using LINQ's 'Where' method.
|
|
* @kind problem
|
|
* @problem.severity recommendation
|
|
* @precision high
|
|
* @id cs/linq/missed-where
|
|
* @tags maintainability
|
|
* language-features
|
|
*/
|
|
|
|
import csharp
|
|
import Helpers
|
|
|
|
from ForeachStmt fes, IfStmt is
|
|
where
|
|
missedWhereOpportunity(fes, is) and
|
|
not missedAllOpportunity(fes)
|
|
select fes,
|
|
"This foreach loop implicitly filters its target sequence $@ - consider filtering the sequence explicitly using '.Where(...)'.",
|
|
is.getCondition(), "here"
|