Skip to content

Commit bd1f45e

Browse files
committed
if VariableNode is used, then so is variableNode
1 parent 46c9146 commit bd1f45e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ql/ql/src/codeql_ql/style/DeadCodeQuery.qll

+18-1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ private File benignUnqueryableFile() {
288288
result.getAbsolutePath().matches("%/ql/ql/test%")
289289
}
290290

291+
import NodeName
292+
291293
/**
292294
* Gets an AstNode that does not affect any query result.
293295
* Is interresting as an quick-eval target to investigate dead code.
@@ -297,5 +299,20 @@ AstNode unQueryable() {
297299
not result = queryable() and
298300
not result = deprecated() and
299301
not result = benignUnqueryable() and
300-
not result.getParent() = any(AstNode node | not node = queryable())
302+
not result.getParent() = any(AstNode node | not node = queryable()) and
303+
// remove where a queryable feature with the "same" name exists.
304+
not exists(AstNode other, string name |
305+
name = getName(result, _) and
306+
name = oppositeFirstLetter(getName(other, _)) and
307+
other.getParent() = result.getParent()
308+
)
309+
}
310+
311+
bindingset[name]
312+
string oppositeFirstLetter(string name) {
313+
exists(string first | first = name.prefix(1) |
314+
if first.toUpperCase() = first
315+
then result = first.toLowerCase() + name.suffix(1)
316+
else result = first.toUpperCase() + name.suffix(1)
317+
)
301318
}

0 commit comments

Comments
 (0)