Skip to content

Commit 3aae1d1

Browse files
author
Esben Sparre Andreasen
committed
JS: avoid two uses of getChildExpr(0)
1 parent 15123da commit 3aae1d1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

javascript/ql/src/semmle/javascript/DefensiveProgramming.qll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,11 @@ module Internal {
239239
op.getRightOperand() = result
240240
)
241241
or
242-
exists(IfStmt c |
243-
c.getCondition() = guard |
244-
result = c.getAControlledStmt().getChildExpr(0) or
245-
result = c.getAControlledStmt().(BlockStmt).getStmt(0).getChildExpr(0)
242+
exists(IfStmt c, ExprStmt guardedStmt |
243+
c.getCondition() = guard and
244+
result = guardedStmt.getExpr() |
245+
guardedStmt = c.getAControlledStmt() or
246+
guardedStmt = c.getAControlledStmt().(BlockStmt).getStmt(0)
246247
)
247248
or
248249
exists (ConditionalExpr c |

0 commit comments

Comments
 (0)