Merge pull request #38 from github/rankOne

add a query for finding rank[1]
This commit is contained in:
Erik Krogh Kristensen
2021-08-18 23:23:00 +02:00
committed by GitHub

View File

@@ -0,0 +1,16 @@
/**
* @name Selecting minimum element using `rank[1]`
* @description Selecting the minimum element using `rank[1](..)` performs worse than doing the same thing with `min(..)`.
* @kind problem
* @problem.severity warning
* @id ql/rank-one
* @tags performance,
* maintainability
* @precision very-high
*/
import ql
from Rank r
where r.getRankExpr().(Integer).getValue() = 1
select r, "Using rank[1](..) is an anti-pattern, use min(..) instead."