diff --git a/javascript/ql/src/Expressions/RedundantExpression.ql b/javascript/ql/src/Expressions/RedundantExpression.ql index b35c0980706..e06a7047f4e 100644 --- a/javascript/ql/src/Expressions/RedundantExpression.ql +++ b/javascript/ql/src/Expressions/RedundantExpression.ql @@ -64,7 +64,10 @@ class RedundantIdemnecantOperand extends RedundantOperand { * arguments to integers. For example, `x&x` is a common idiom for converting `x` to an integer. */ class RedundantIdempotentOperand extends RedundantOperand { - RedundantIdempotentOperand() { getParent() instanceof LogicalBinaryExpr } + RedundantIdempotentOperand() { + getParent() instanceof LogicalBinaryExpr and + not exists(UpdateExpr e | e.getParentExpr+() = this) + } } /** diff --git a/javascript/ql/test/query-tests/Expressions/RedundantExpression/tst.js b/javascript/ql/test/query-tests/Expressions/RedundantExpression/tst.js index baf59de5f1e..b556d518eca 100644 --- a/javascript/ql/test/query-tests/Expressions/RedundantExpression/tst.js +++ b/javascript/ql/test/query-tests/Expressions/RedundantExpression/tst.js @@ -6,4 +6,6 @@ x == 23 || x == 23; x & x; // this may actually be OK, but it's not good style -pop() && pop(); \ No newline at end of file +pop() && pop(); + +foo[bar++] && foo[bar++] // OK \ No newline at end of file