mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
still flag single-expression files that contain a function
This commit is contained in:
@@ -159,6 +159,10 @@ predicate hasNoEffect(Expr e) {
|
||||
not e.(ParExpr).getExpression().getLastToken().getNextToken().getValue() = ":" and
|
||||
// exclude the first statement of a try block
|
||||
not e = any(TryStmt stmt).getBody().getStmt(0).(ExprStmt).getExpr() and
|
||||
// exclude expressions that are alone in a file
|
||||
not e.getParent().(ExprStmt).getParent().(TopLevel).getNumChild() = 1
|
||||
// exclude expressions that are alone in a file, and file doesn't contain a function.
|
||||
not exists(TopLevel top |
|
||||
top = e.getParent().(ExprStmt).getParent() and
|
||||
top.getNumChild() = 1 and
|
||||
not exists(Function fun | fun.getEnclosingContainer() = top)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
["foo", "bar", 123]
|
||||
Reference in New Issue
Block a user