mirror of
https://github.com/github/codeql.git
synced 2026-03-04 06:36:46 +01:00
26 lines
671 B
Plaintext
26 lines
671 B
Plaintext
/**
|
|
* @name Redundant Select
|
|
* @description Writing 'seq.Select(e => e)' or 'from e in seq select e' is redundant.
|
|
* @kind problem
|
|
* @problem.severity warning
|
|
* @precision very-high
|
|
* @id cs/linq/useless-select
|
|
* @tags quality
|
|
* maintainability
|
|
* useless-code
|
|
* language-features
|
|
* external/cwe/cwe-561
|
|
*/
|
|
|
|
import csharp
|
|
import Linq.Helpers
|
|
|
|
predicate isIdentityFunction(AnonymousFunctionExpr afe) {
|
|
afe.getNumberOfParameters() = 1 and
|
|
afe.getExpressionBody() = afe.getParameter(0).getAnAccess()
|
|
}
|
|
|
|
from SelectCall sc
|
|
where isIdentityFunction(sc.getFunctionExpr())
|
|
select sc, "This LINQ selection is redundant and can be removed."
|