Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e6a190c

Browse files
author
Esben Sparre Andreasen
committed
JS: replace .stripParens query uses w. .getUnderlyingReference
1 parent f04293f commit e6a190c

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

javascript/ql/src/Expressions/BadParityCheck.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ predicate maybeNegativeVar(Variable v) {
6565
// is v ever assigned a potentially negative value?
6666
maybeNegative(v.getAnAssignedExpr()) or
6767
// is v ever decremented?
68-
exists (DecExpr dec | dec.getOperand().stripParens() = v.getAnAccess()) or
68+
exists (DecExpr dec | dec.getOperand().getUnderlyingReference() = v.getAnAccess()) or
6969
// is v ever subject to a compound assignment other than +=, or to
7070
// += with potentially negative rhs?
7171
exists (CompoundAssignExpr assgn | assgn.getTarget() = v.getAnAccess() |

javascript/ql/src/Statements/SuspiciousUnusedLoopIterationVariable.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class IncrementExpr extends Expr {
2626
// x = x + e
2727
exists (AssignExpr assgn, Variable v | assgn = this |
2828
assgn.getTarget() = v.getAnAccess() and
29-
assgn.getRhs().(AddExpr).getAnOperand().stripParens() = v.getAnAccess()
29+
assgn.getRhs().(AddExpr).getAnOperand().getUnderlyingReference() = v.getAnAccess()
3030
)
3131
}
3232
}

javascript/ql/src/Statements/UselessConditional.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import semmle.javascript.dataflow.Refinements
2828
*/
2929
predicate isDefensiveInit(VarAccess va) {
3030
exists (LogOrExpr o, VarRef va2 |
31-
va = o.getLeftOperand().stripParens() and va2.getVariable() = va.getVariable() |
31+
va = o.getLeftOperand().getUnderlyingReference() and va2.getVariable() = va.getVariable() |
3232
exists (AssignExpr assgn | va2 = assgn.getTarget() |
3333
assgn = o.getRightOperand().stripParens() or
3434
o = assgn.getRhs().getUnderlyingValue()

javascript/ql/src/definitions.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private import Declarations.Declarations
1919
* `x` has kind `"V"`.
2020
*/
2121
string refKind(RefExpr r) {
22-
if exists(InvokeExpr invk | r = invk.getCallee().stripParens()) then
22+
if exists(InvokeExpr invk | r = invk.getCallee().getUnderlyingReference()) then
2323
result = "M"
2424
else
2525
result = "V"
@@ -143,7 +143,7 @@ predicate typedInvokeLookup(ASTNode ref, ASTNode decl, string kind) {
143143
not variableDefLookup(ref, decl, _) and
144144
not propertyLookup(ref, decl, _) and
145145
exists (InvokeExpr invoke, Expr callee |
146-
callee = invoke.getCallee().stripParens() and
146+
callee = invoke.getCallee().getUnderlyingReference() and
147147
(ref = callee.(Identifier) or ref = callee.(DotExpr).getPropertyNameExpr()) and
148148
decl = invoke.getResolvedCallee() and
149149
kind = "M")

0 commit comments

Comments
 (0)