Ruby: Remove isSplatAll arg/parameter position

This is equivalent to isSplat(0).
This commit is contained in:
Harry Maclean
2023-08-15 12:26:40 +01:00
parent 222aa41bbf
commit 0bbda992fb
2 changed files with 5 additions and 28 deletions

View File

@@ -438,7 +438,6 @@ private module Cached {
FlowSummaryImplSpecific::ParsePositions::isParsedKeywordParameterPosition(_, name)
} or
THashSplatArgumentPosition() or
TSplatAllArgumentPosition() or
TSplatArgumentPosition(int pos) { exists(Call c | c.getArgument(pos) instanceof SplatExpr) } or
TSynthSplatArgumentPosition() or
TAnyArgumentPosition() or
@@ -469,7 +468,6 @@ private module Cached {
// position for multiple parameter nodes in the same callable, we introduce this
// synthetic parameter position.
TSynthHashSplatParameterPosition() or
TSplatAllParameterPosition() or
TSplatParameterPosition(int pos) {
exists(Parameter p | p.getPosition() = pos and p instanceof SplatParameter)
} or
@@ -1300,8 +1298,6 @@ class ParameterPosition extends TParameterPosition {
// A fake position to indicate that this parameter node holds content from a synth arg splat node
predicate isSynthArgSplat() { this = TSynthArgSplatParameterPosition() }
predicate isSplatAll() { this = TSplatAllParameterPosition() }
predicate isSplat(int n) { this = TSplatParameterPosition(n) }
/**
@@ -1329,8 +1325,6 @@ class ParameterPosition extends TParameterPosition {
or
this.isSynthHashSplat() and result = "synthetic **"
or
this.isSplatAll() and result = "*"
or
this.isAny() and result = "any"
or
this.isAnyNamed() and result = "any-named"
@@ -1372,8 +1366,6 @@ class ArgumentPosition extends TArgumentPosition {
*/
predicate isHashSplat() { this = THashSplatArgumentPosition() }
predicate isSplatAll() { this = TSplatAllArgumentPosition() }
predicate isSplat(int n) { this = TSplatArgumentPosition(n) }
predicate isSynthSplat() { this = TSynthSplatArgumentPosition() }
@@ -1394,8 +1386,6 @@ class ArgumentPosition extends TArgumentPosition {
or
this.isHashSplat() and result = "**"
or
this.isSplatAll() and result = "*"
or
this.isSynthSplat() and result = "synthetic *"
or
exists(int pos | this.isSplat(pos) and result = "* (position " + pos + ")")
@@ -1427,11 +1417,9 @@ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) {
or
ppos.isSynthHashSplat() and apos.isHashSplat()
or
ppos.isSplatAll() and apos.isSplatAll()
ppos.isSplat(0) and apos.isSynthSplat()
or
ppos.isSplatAll() and apos.isSynthSplat()
or
ppos.isSynthSplat() and apos.isSplatAll()
ppos.isSynthSplat() and apos.isSplat(0)
or
apos.isSynthSplat() and ppos.isSynthArgSplat()
or

View File

@@ -245,12 +245,7 @@ private class Argument extends CfgNodes::ExprCfgNode {
this.getExpr() instanceof HashSplatExpr and
arg.isHashSplat()
or
this = call.getArgument(0) and
not exists(call.getArgument(1)) and
this.getExpr() instanceof SplatExpr and
arg.isSplatAll()
or
exists(int pos | pos > 0 or exists(call.getArgument(pos + 1)) |
exists(int pos |
this = call.getArgument(pos) and
this.getExpr() instanceof SplatExpr and
arg.isSplat(pos)
@@ -370,9 +365,7 @@ private module Cached {
} or
TSynthSplatArgumentNode(CfgNodes::ExprNodes::CallCfgNode c) {
exists(Argument arg, ArgumentPosition pos | pos.isPositional(_) | arg.isArgumentOf(c, pos)) and
not exists(Argument arg, ArgumentPosition pos | pos.isSplat(_) or pos.isSplatAll() |
arg.isArgumentOf(c, pos)
)
not exists(Argument arg, ArgumentPosition pos | pos.isSplat(_) | arg.isArgumentOf(c, pos))
}
class TSourceParameterNode =
@@ -695,11 +688,7 @@ private module ParameterNodes {
parameter = callable.getAParameter().(HashSplatParameter) and
pos.isHashSplat()
or
parameter = callable.getParameter(0).(SplatParameter) and
not exists(callable.getParameter(1)) and
pos.isSplatAll()
or
exists(int n | n > 0 |
exists(int n |
parameter = callable.getParameter(n).(SplatParameter) and
pos.isSplat(n) and
// There are no positional parameters after the splat