mirror of
https://github.com/github/codeql.git
synced 2026-02-07 18:51:06 +01:00
Merge pull request #38 from github/rankOne
add a query for finding rank[1]
This commit is contained in:
16
ql/src/queries/style/RankOne.ql
Normal file
16
ql/src/queries/style/RankOne.ql
Normal 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."
|
||||
Reference in New Issue
Block a user