File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
test/query-tests/Expressions/ExprHasNoEffect Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,10 @@ predicate hasNoEffect(Expr e) {
159
159
not e .( ParExpr ) .getExpression ( ) .getLastToken ( ) .getNextToken ( ) .getValue ( ) = ":" and
160
160
// exclude the first statement of a try block
161
161
not e = any ( TryStmt stmt ) .getBody ( ) .getStmt ( 0 ) .( ExprStmt ) .getExpr ( ) and
162
- // exclude expressions that are alone in a file
163
- not e .getParent ( ) .( ExprStmt ) .getParent ( ) .( TopLevel ) .getNumChild ( ) = 1
162
+ // exclude expressions that are alone in a file, and file doesn't contain a function.
163
+ not exists ( TopLevel top |
164
+ top = e .getParent ( ) .( ExprStmt ) .getParent ( ) and
165
+ top .getNumChild ( ) = 1 and
166
+ not exists ( Function fun | fun .getEnclosingContainer ( ) = top )
167
+ )
164
168
}
Original file line number Diff line number Diff line change
1
+ [ "foo" , "bar" , 123 ]
You can’t perform that action at this time.
0 commit comments