Skip to content

Commit 3b6dae4

Browse files
committed
JavaScript: Remove omittable exists variables
1 parent 32471d3 commit 3b6dae4

File tree

20 files changed

+36
-57
lines changed

20 files changed

+36
-57
lines changed

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/EndpointFeatures.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ private module FunctionNames {
5555
private string getApproximateNameForFunction(Function function) {
5656
count(DataFlow::CallNode call, int index | functionUsedAsArgumentToCall(function, call, index)) =
5757
1 and
58-
exists(DataFlow::CallNode call, int index, string basePart |
59-
functionUsedAsArgumentToCall(function, call, index) and
58+
exists(DataFlow::CallNode call, string basePart |
59+
functionUsedAsArgumentToCall(function, call, _) and
6060
(
6161
if count(getReceiverName(call)) = 1
6262
then basePart = getReceiverName(call) + "."

javascript/ql/experimental/adaptivethreatmodeling/modelbuilding/extraction/ExtractEndpointDataTraining.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ predicate tokenFeatures(DataFlow::Node endpoint, string featureName, string feat
3030
or
3131
// Performance note: this creates a Cartesian product between `endpoint` and `featureName`.
3232
featureName = EndpointFeatures::getASupportedFeatureName() and
33-
not exists(string value | EndpointFeatures::tokenFeatures(endpoint, featureName, value)) and
33+
not EndpointFeatures::tokenFeatures(endpoint, featureName, _) and
3434
featureValue = ""
3535
)
3636
}

javascript/ql/lib/semmle/javascript/DOM.qll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,7 @@ module DOM {
465465
*/
466466
private DataFlow::SourceNode nonFirstLocationType(DataFlow::TypeTracker t) {
467467
// One step inlined in the beginning.
468-
exists(DataFlow::TypeTracker t2 |
469-
result =
470-
any(DataFlow::Node n | n.hasUnderlyingType("Location")).getALocalSource().track(t2, t)
471-
)
468+
result = any(DataFlow::Node n | n.hasUnderlyingType("Location")).getALocalSource().track(_, t)
472469
or
473470
exists(DataFlow::TypeTracker t2 | result = nonFirstLocationType(t2).track(t2, t))
474471
}

javascript/ql/lib/semmle/javascript/DefUse.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ deprecated private int nextDefAfter(BasicBlock bb, Variable v, int i, VarDef d)
302302
* DEPRECATED: Use the `SSA.qll` library instead.
303303
*/
304304
deprecated predicate localDefinitionOverwrites(LocalVariable v, VarDef earlier, VarDef later) {
305-
exists(BasicBlock bb, int i, int next | next = nextDefAfter(bb, v, i, earlier) |
305+
exists(BasicBlock bb, int next | next = nextDefAfter(bb, v, _, earlier) |
306306
bb.defAt(next, v, later)
307307
or
308308
exists(BasicBlock succ | succ = bb.getASuccessor() |

javascript/ql/lib/semmle/javascript/Expr.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ class ObjectExpr extends @obj_expr, Expr {
571571
Property getProperty(int i) { properties(result, this, i, _, _) }
572572

573573
/** Gets a property in this object literal. */
574-
Property getAProperty() { exists(int i | result = this.getProperty(i)) }
574+
Property getAProperty() { result = this.getProperty(_) }
575575

576576
/** Gets the number of properties in this object literal. */
577577
int getNumProperty() { result = count(this.getAProperty()) }

javascript/ql/lib/semmle/javascript/Functions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Function extends @function, Parameterized, TypeParameterized, StmtContaine
4747
}
4848

4949
/** Gets a parameter of this function. */
50-
override Parameter getAParameter() { exists(int idx | result = this.getParameter(idx)) }
50+
override Parameter getAParameter() { result = this.getParameter(_) }
5151

5252
/** Gets the parameter named `name` of this function, if any. */
5353
SimpleParameter getParameterByName(string name) {

javascript/ql/lib/semmle/javascript/NodeJS.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class Require extends CallExpr, Import {
316316
override Module resolveImportedPath() {
317317
moduleInFile(result, this.load(min(int prio | moduleInFile(_, this.load(prio)))))
318318
or
319-
not exists(Module mod | moduleInFile(mod, this.load(_))) and
319+
not moduleInFile(_, this.load(_)) and
320320
result = Import.super.resolveImportedPath()
321321
}
322322

javascript/ql/lib/semmle/javascript/Routing.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ module Routing {
723723
isInstalledAt(result, router, node)
724724
or
725725
result = getMostRecentRouteSetupAt(router, node.getAPredecessor()) and
726-
not exists(RouteSetup setup | isInstalledAt(setup, router, node))
726+
not isInstalledAt(_, router, node)
727727
}
728728

729729
/**
@@ -977,8 +977,8 @@ module Routing {
977977
* Holds if `pred -> succ` is a data-flow step between access paths on request input objects.
978978
*/
979979
private predicate middlewareDataFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
980-
exists(Node writer, Node reader, int n, string path |
981-
potentialAccessPathStep(writer, pred, reader, succ, n, path) and
980+
exists(Node writer, Node reader |
981+
potentialAccessPathStep(writer, pred, reader, succ, _, _) and
982982
pragma[only_bind_out](reader).isGuardedByNode(pragma[only_bind_out](writer))
983983
)
984984
or

javascript/ql/lib/semmle/javascript/dataflow/Configuration.qll

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,9 +1155,9 @@ private predicate parameterPropRead(
11551155
DataFlow::Node arg, string prop, DataFlow::Node succ, DataFlow::Configuration cfg,
11561156
PathSummary summary
11571157
) {
1158-
exists(Function f, DataFlow::Node read, DataFlow::Node invk, DataFlow::Node parm |
1158+
exists(Function f, DataFlow::Node read |
11591159
reachesReturn(f, read, cfg, summary) and
1160-
parameterPropReadStep(parm, read, prop, cfg, arg, invk, f, succ)
1160+
parameterPropReadStep(_, read, prop, cfg, arg, _, f, succ)
11611161
)
11621162
}
11631163

@@ -1764,11 +1764,8 @@ private PathNode getASuccessor(PathNode nd) {
17641764
result = initialMidNode(nd)
17651765
or
17661766
// mid node to mid node
1767-
exists(
1768-
Configuration cfg, DataFlow::Node predNd, PathSummary summary, DataFlow::Node succNd,
1769-
PathSummary newSummary
1770-
|
1771-
midNodeStep(nd, predNd, cfg, summary, succNd, newSummary) and
1767+
exists(Configuration cfg, PathSummary summary, DataFlow::Node succNd, PathSummary newSummary |
1768+
midNodeStep(nd, _, cfg, summary, succNd, newSummary) and
17721769
result = MkMidNode(succNd, id(cfg), summary.append(newSummary))
17731770
)
17741771
or

javascript/ql/lib/semmle/javascript/dataflow/Portals.qll

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,14 @@ private module NpmPackagePortal {
196196

197197
/** Holds if `imp` is an import of package `pkgName`. */
198198
predicate imports(DataFlow::SourceNode imp, string pkgName) {
199-
exists(NpmPackage pkg |
200-
imp = getAModuleImport(pkg, pkgName) and
201-
pkgName.regexpMatch("[^./].*")
202-
)
199+
imp = getAModuleImport(_, pkgName) and
200+
pkgName.regexpMatch("[^./].*")
203201
}
204202

205203
/** Holds if `imp` imports `member` from package `pkgName`. */
206204
predicate imports(DataFlow::SourceNode imp, string pkgName, string member) {
207-
exists(NpmPackage pkg |
208-
imp = getAModuleMemberImport(pkg, pkgName, member) and
209-
pkgName.regexpMatch("[^./].*")
210-
)
205+
imp = getAModuleMemberImport(_, pkgName, member) and
206+
pkgName.regexpMatch("[^./].*")
211207
}
212208

213209
/** Gets the main module of package `pkgName`. */
@@ -404,7 +400,7 @@ private module InstancePortal {
404400
* right-hand side of that definition.
405401
*/
406402
predicate instanceMemberDef(Portal base, string name, DataFlow::Node rhs, boolean escapes) {
407-
exists(AbstractInstance i, DataFlow::SourceNode ctor | isInstance(base, ctor, i, escapes) |
403+
exists(DataFlow::SourceNode ctor | isInstance(base, ctor, _, escapes) |
408404
// ES2015 instance method
409405
exists(MemberDefinition mem |
410406
mem = ctor.getAstNode().(ClassDefinition).getAMember() and

0 commit comments

Comments
 (0)