add a query for finding rank[1]

This commit is contained in:
Erik Krogh Kristensen
2021-08-18 09:19:05 +00:00
committed by GitHub
parent bc2932383b
commit feb1ab86f0

View File

@@ -0,0 +1,16 @@
/**
* @name Selecting minimum element using `rank[1]`
* @description Selecting the minimim 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."