Skip to content

Commit 4355f8d

Browse files
authored
Merge pull request github#3023 from erik-krogh/RedundantUpdate
Approved by esbena
2 parents ecded4c + dd261c5 commit 4355f8d

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

change-notes/1.24/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
| Syntax error (`js/syntax-error`) | Lower severity | This results of this query are now displayed with lower severity. |
6969
| Use of password hash with insufficient computational effort (`js/insufficient-password-hash`) | Fewer false positive results | This query now recognizes additional cases that do not require secure hashing. |
7070
| Useless regular-expression character escape (`js/useless-regexp-character-escape`) | Fewer false positive results | This query now distinguishes escapes in strings and regular expression literals. |
71+
| Identical operands (`js/redundant-operation`) | Fewer results | This query now recognizes cases where the operands change a value using ++/-- expressions. |
7172

7273
## Changes to libraries
7374

javascript/ql/src/Expressions/RedundantExpression.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ class RedundantIdemnecantOperand extends RedundantOperand {
6464
* arguments to integers. For example, `x&x` is a common idiom for converting `x` to an integer.
6565
*/
6666
class RedundantIdempotentOperand extends RedundantOperand {
67-
RedundantIdempotentOperand() { getParent() instanceof LogicalBinaryExpr }
67+
RedundantIdempotentOperand() {
68+
getParent() instanceof LogicalBinaryExpr and
69+
not exists(UpdateExpr e | e.getParentExpr+() = this)
70+
}
6871
}
6972

7073
/**

javascript/ql/test/query-tests/Expressions/RedundantExpression/tst.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ x == 23 || x == 23;
66
x & x;
77

88
// this may actually be OK, but it's not good style
9-
pop() && pop();
9+
pop() && pop();
10+
11+
foo[bar++] && foo[bar++] // OK

0 commit comments

Comments
 (0)