CodeQL language preview
1. Unused variable query
a QLDoc header, a predicate check, and a select placeholder
horizon-dark
/**
* @name Unused variable
* @kind problem
* @problem.severity warning
*/
import javascript
from Variable v
where not exists(VarAccess a | a.getVariable() = v)
select v, "Unused variable $@.", v, v.getName()
atom-one-dark
/**
* @name Unused variable
* @kind problem
* @problem.severity warning
*/
import javascript
from Variable v
where not exists(VarAccess a | a.getVariable() = v)
select v, "Unused variable $@.", v, v.getName()
github-dark
/**
* @name Unused variable
* @kind problem
* @problem.severity warning
*/
import javascript
from Variable v
where not exists(VarAccess a | a.getVariable() = v)
select v, "Unused variable $@.", v, v.getName()
dracula
/**
* @name Unused variable
* @kind problem
* @problem.severity warning
*/
import javascript
from Variable v
where not exists(VarAccess a | a.getVariable() = v)
select v, "Unused variable $@.", v, v.getName()
nord
/**
* @name Unused variable
* @kind problem
* @problem.severity warning
*/
import javascript
from Variable v
where not exists(VarAccess a | a.getVariable() = v)
select v, "Unused variable $@.", v, v.getName()
github
/**
* @name Unused variable
* @kind problem
* @problem.severity warning
*/
import javascript
from Variable v
where not exists(VarAccess a | a.getVariable() = v)
select v, "Unused variable $@.", v, v.getName()
2. A predicate
a reusable predicate definition
horizon-dark
predicate isEven(int x) {
x % 2 = 0
} atom-one-dark
predicate isEven(int x) {
x % 2 = 0
} github-dark
predicate isEven(int x) {
x % 2 = 0
} dracula
predicate isEven(int x) {
x % 2 = 0
} nord
predicate isEven(int x) {
x % 2 = 0
} github
predicate isEven(int x) {
x % 2 = 0
} 3. Aggregations
count and exists in a where clause
horizon-dark
from Function f
where count(f.getAParameter()) > 5
select f, "Too many parameters" atom-one-dark
from Function f
where count(f.getAParameter()) > 5
select f, "Too many parameters" github-dark
from Function f
where count(f.getAParameter()) > 5
select f, "Too many parameters" dracula
from Function f
where count(f.getAParameter()) > 5
select f, "Too many parameters" nord
from Function f
where count(f.getAParameter()) > 5
select f, "Too many parameters" github
from Function f
where count(f.getAParameter()) > 5
select f, "Too many parameters"