Skip to content

Commit b8a368a

Browse files
authored
QL: Merge pull request #38 from github/rankOne
add a query for finding rank[1]
2 parents 08dd947 + 23b2d43 commit b8a368a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

ql/src/queries/style/RankOne.ql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @name Selecting minimum element using `rank[1]`
3+
* @description Selecting the minimum element using `rank[1](..)` performs worse than doing the same thing with `min(..)`.
4+
* @kind problem
5+
* @problem.severity warning
6+
* @id ql/rank-one
7+
* @tags performance,
8+
* maintainability
9+
* @precision very-high
10+
*/
11+
12+
import ql
13+
14+
from Rank r
15+
where r.getRankExpr().(Integer).getValue() = 1
16+
select r, "Using rank[1](..) is an anti-pattern, use min(..) instead."

0 commit comments

Comments
 (0)