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

Skip to content

Commit 43e215c

Browse files
author
Esben Sparre Andreasen
committed
JS: replace .stripParens query uses w. .getUnderlyingValue
1 parent 030d920 commit 43e215c

7 files changed

Lines changed: 14 additions & 14 deletions

File tree

javascript/ql/src/Declarations/BuiltinRedefined.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ predicate acceptableRedefinition(Identifier id) {
2727
// Date = global.Date
2828
exists (AssignExpr assgn |
2929
id = assgn.getTarget() and
30-
id.getName() = assgn.getRhs().stripParens().(PropAccess).getPropertyName()
30+
id.getName() = assgn.getRhs().getUnderlyingValue().(PropAccess).getPropertyName()
3131
) or
3232
// var Date = global.Date
3333
exists (VariableDeclarator decl |
3434
id = decl.getBindingPattern() and
35-
id.getName() = decl.getInit().stripParens().(PropAccess).getPropertyName()
35+
id.getName() = decl.getInit().getUnderlyingValue().(PropAccess).getPropertyName()
3636
)
3737
}
3838

javascript/ql/src/Declarations/UnusedParameter.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import javascript
1010
* Holds if `e` is an expression whose value is invoked as a function.
1111
*/
1212
private predicate isCallee(Expr e) {
13-
exists (InvokeExpr invk | e = invk.getCallee().stripParens())
13+
exists (InvokeExpr invk | e = invk.getCallee().getUnderlyingValue())
1414
}
1515

1616
/**

javascript/ql/src/Expressions/BitwiseSignCheck.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ predicate acceptableSignCheck(BitwiseExpr b) {
3737
* is sign-preserving, we shouldn't flag it (and we allow arbitrary shifts, not just 16-bit ones)
3838
*/
3939
exists (RShiftExpr rsh, LShiftExpr lsh |
40-
rsh = b and lsh = rsh.getLeftOperand().stripParens() and
40+
rsh = b and lsh = rsh.getLeftOperand().getUnderlyingValue() and
4141
lsh.getRightOperand().getIntValue() = rsh.getRightOperand().getIntValue()
4242
)
4343
}
4444

4545
from Comparison e, BitwiseExpr b
46-
where b = e.getLeftOperand().stripParens() and
46+
where b = e.getLeftOperand().getUnderlyingValue() and
4747
not e instanceof EqualityTest and
4848
e.getRightOperand().getIntValue() = 0 and
4949
not acceptableSignCheck(b)

javascript/ql/src/Expressions/RedundantExpression.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class RedundantIdemnecantOperand extends RedundantOperand {
5858
exists (IdemnecantExpr parent |
5959
parent = getParent() and
6060
// exclude trivial cases like `1-1`
61-
not parent.getRightOperand().stripParens() instanceof Literal
61+
not parent.getRightOperand().getUnderlyingValue() instanceof Literal
6262
)
6363
}
6464
}
@@ -80,7 +80,7 @@ class RedundantIdempotentOperand extends RedundantOperand {
8080
*/
8181
class AverageExpr extends DivExpr {
8282
AverageExpr() {
83-
getLeftOperand().stripParens() instanceof AddExpr and
83+
getLeftOperand().getUnderlyingValue() instanceof AddExpr and
8484
getRightOperand().getIntValue() = 2
8585
}
8686
}
@@ -91,12 +91,12 @@ class AverageExpr extends DivExpr {
9191
class RedundantAverageOperand extends RedundantOperand {
9292
RedundantAverageOperand() {
9393
exists (AverageExpr aver |
94-
(AddExpr)getParent() = aver.getLeftOperand().stripParens()
94+
(AddExpr)getParent() = aver.getLeftOperand().getUnderlyingValue()
9595
)
9696
}
9797

9898
override AverageExpr toReport() {
99-
getParent() = result.getLeftOperand().stripParens()
99+
getParent() = result.getLeftOperand().getUnderlyingValue()
100100
}
101101
}
102102

javascript/ql/src/LanguageFeatures/BadTypeof.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class EqOrSwitch extends ASTNode {
4747
}
4848

4949
from EqOrSwitch et, TypeofExpr typeof, ConstantString str
50-
where typeof = et.getAnOperand().stripParens() and
51-
str = et.getAnOperand().stripParens() and
50+
where typeof = et.getAnOperand().getUnderlyingValue() and
51+
str = et.getAnOperand().getUnderlyingValue() and
5252
not str.getStringValue().regexpMatch("undefined|boolean|number|string|object|function|symbol|unknown|date|bigint")
5353
select typeof, "The result of this 'typeof' expression is compared to '$@', but the two can never be equal.", str, str.getStringValue()

javascript/ql/src/Statements/ImplicitReturn.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int numRet(Function f) {
5656
predicate isDualUseConstructor(Function f) {
5757
numRet(f) = 1 and
5858
exists (ReturnStmt ret, DataFlow::NewNode new | ret.getContainer() = f |
59-
new.asExpr() = ret.getExpr().stripParens() and
59+
new.asExpr() = ret.getExpr().getUnderlyingValue() and
6060
new.getACallee() = f
6161
)
6262
}

javascript/ql/src/Statements/UselessConditional.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ predicate isDefensiveInit(VarAccess va) {
3131
va = o.getLeftOperand().stripParens() and va2.getVariable() = va.getVariable() |
3232
exists (AssignExpr assgn | va2 = assgn.getTarget() |
3333
assgn = o.getRightOperand().stripParens() or
34-
o = assgn.getRhs().stripParens()
34+
o = assgn.getRhs().getUnderlyingValue()
3535
) or
3636
exists (VariableDeclarator vd | va2 = vd.getBindingPattern() |
37-
o = vd.getInit().stripParens()
37+
o = vd.getInit().getUnderlyingValue()
3838
)
3939
)
4040
}

0 commit comments

Comments
 (0)