Skip to content

Commit 0bbda99

Browse files
committed
Ruby: Remove isSplatAll arg/parameter position
This is equivalent to isSplat(0).
1 parent 222aa41 commit 0bbda99

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ private module Cached {
438438
FlowSummaryImplSpecific::ParsePositions::isParsedKeywordParameterPosition(_, name)
439439
} or
440440
THashSplatArgumentPosition() or
441-
TSplatAllArgumentPosition() or
442441
TSplatArgumentPosition(int pos) { exists(Call c | c.getArgument(pos) instanceof SplatExpr) } or
443442
TSynthSplatArgumentPosition() or
444443
TAnyArgumentPosition() or
@@ -469,7 +468,6 @@ private module Cached {
469468
// position for multiple parameter nodes in the same callable, we introduce this
470469
// synthetic parameter position.
471470
TSynthHashSplatParameterPosition() or
472-
TSplatAllParameterPosition() or
473471
TSplatParameterPosition(int pos) {
474472
exists(Parameter p | p.getPosition() = pos and p instanceof SplatParameter)
475473
} or
@@ -1300,8 +1298,6 @@ class ParameterPosition extends TParameterPosition {
13001298
// A fake position to indicate that this parameter node holds content from a synth arg splat node
13011299
predicate isSynthArgSplat() { this = TSynthArgSplatParameterPosition() }
13021300

1303-
predicate isSplatAll() { this = TSplatAllParameterPosition() }
1304-
13051301
predicate isSplat(int n) { this = TSplatParameterPosition(n) }
13061302

13071303
/**
@@ -1329,8 +1325,6 @@ class ParameterPosition extends TParameterPosition {
13291325
or
13301326
this.isSynthHashSplat() and result = "synthetic **"
13311327
or
1332-
this.isSplatAll() and result = "*"
1333-
or
13341328
this.isAny() and result = "any"
13351329
or
13361330
this.isAnyNamed() and result = "any-named"
@@ -1372,8 +1366,6 @@ class ArgumentPosition extends TArgumentPosition {
13721366
*/
13731367
predicate isHashSplat() { this = THashSplatArgumentPosition() }
13741368

1375-
predicate isSplatAll() { this = TSplatAllArgumentPosition() }
1376-
13771369
predicate isSplat(int n) { this = TSplatArgumentPosition(n) }
13781370

13791371
predicate isSynthSplat() { this = TSynthSplatArgumentPosition() }
@@ -1394,8 +1386,6 @@ class ArgumentPosition extends TArgumentPosition {
13941386
or
13951387
this.isHashSplat() and result = "**"
13961388
or
1397-
this.isSplatAll() and result = "*"
1398-
or
13991389
this.isSynthSplat() and result = "synthetic *"
14001390
or
14011391
exists(int pos | this.isSplat(pos) and result = "* (position " + pos + ")")
@@ -1427,11 +1417,9 @@ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) {
14271417
or
14281418
ppos.isSynthHashSplat() and apos.isHashSplat()
14291419
or
1430-
ppos.isSplatAll() and apos.isSplatAll()
1431-
or
1432-
ppos.isSplatAll() and apos.isSynthSplat()
1420+
ppos.isSplat(0) and apos.isSynthSplat()
14331421
or
1434-
ppos.isSynthSplat() and apos.isSplatAll()
1422+
ppos.isSynthSplat() and apos.isSplat(0)
14351423
or
14361424
apos.isSynthSplat() and ppos.isSynthArgSplat()
14371425
or

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,7 @@ private class Argument extends CfgNodes::ExprCfgNode {
245245
this.getExpr() instanceof HashSplatExpr and
246246
arg.isHashSplat()
247247
or
248-
this = call.getArgument(0) and
249-
not exists(call.getArgument(1)) and
250-
this.getExpr() instanceof SplatExpr and
251-
arg.isSplatAll()
252-
or
253-
exists(int pos | pos > 0 or exists(call.getArgument(pos + 1)) |
248+
exists(int pos |
254249
this = call.getArgument(pos) and
255250
this.getExpr() instanceof SplatExpr and
256251
arg.isSplat(pos)
@@ -370,9 +365,7 @@ private module Cached {
370365
} or
371366
TSynthSplatArgumentNode(CfgNodes::ExprNodes::CallCfgNode c) {
372367
exists(Argument arg, ArgumentPosition pos | pos.isPositional(_) | arg.isArgumentOf(c, pos)) and
373-
not exists(Argument arg, ArgumentPosition pos | pos.isSplat(_) or pos.isSplatAll() |
374-
arg.isArgumentOf(c, pos)
375-
)
368+
not exists(Argument arg, ArgumentPosition pos | pos.isSplat(_) | arg.isArgumentOf(c, pos))
376369
}
377370

378371
class TSourceParameterNode =
@@ -695,11 +688,7 @@ private module ParameterNodes {
695688
parameter = callable.getAParameter().(HashSplatParameter) and
696689
pos.isHashSplat()
697690
or
698-
parameter = callable.getParameter(0).(SplatParameter) and
699-
not exists(callable.getParameter(1)) and
700-
pos.isSplatAll()
701-
or
702-
exists(int n | n > 0 |
691+
exists(int n |
703692
parameter = callable.getParameter(n).(SplatParameter) and
704693
pos.isSplat(n) and
705694
// There are no positional parameters after the splat

0 commit comments

Comments
 (0)