Skip to content

Commit f8a62c4

Browse files
committed
Address comments
1 parent e801d96 commit f8a62c4

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

ruby/ql/lib/codeql/ruby/ast/Control.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,11 @@ class InClause extends Expr, TInClause {
540540

541541
/**
542542
* Gets the pattern guard condition in this case-in expression. In the
543-
* following example, the pattern guard condition is `x > 10`.
543+
* following example, there are two pattern guard conditions `x > 10` and `x < 0`.
544544
* ```rb
545545
* case foo
546546
* in [ x ] if x > 10 then ...
547-
* in [ x ] unless x < 10 then ...
547+
* in [ x ] unless x < 0 then ...
548548
* end
549549
* ```
550550
*/

ruby/ql/lib/codeql/ruby/ast/Pattern.qll

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ class ArrayPattern extends CasePattern, TArrayPattern {
175175
* [ 1, 2, 3, *middle, 4 , 5]
176176
* ```
177177
*/
178-
LocalVariableWriteAccess getRestVariable() {
178+
LocalVariableWriteAccess getRestVariableAccess() {
179179
toGenerated(result) = g.getChild(restIndex()).(Ruby::SplatParameter).getName()
180180
}
181181

182182
/**
183183
* Holds if this pattern permits any unmatched remaining elements, i.e. the pattern does not have a trailing `,`
184184
* and does not contain a rest token (`*` or `*name`) either.
185185
*/
186-
predicate allowUnmatchedElements() { not exists(this.restIndex()) }
186+
predicate allowsUnmatchedElements() { not exists(this.restIndex()) }
187187

188188
private int restIndex() { g.getChild(result) instanceof Ruby::SplatParameter }
189189

@@ -200,7 +200,7 @@ class ArrayPattern extends CasePattern, TArrayPattern {
200200
or
201201
pred = "getSuffixElement" and result = this.getSuffixElement(_)
202202
or
203-
pred = "getRestVariable" and result = this.getRestVariable()
203+
pred = "getRestVariableAccess" and result = this.getRestVariableAccess()
204204
}
205205
}
206206

@@ -232,7 +232,7 @@ class FindPattern extends CasePattern, TFindPattern {
232232
* in List[*init, "a", Integer => x, *tail]
233233
* ```
234234
*/
235-
LocalVariableWriteAccess getPrefix() {
235+
LocalVariableWriteAccess getPrefixVariableAccess() {
236236
toGenerated(result) = g.getChild(0).(Ruby::SplatParameter).getName()
237237
}
238238

@@ -242,7 +242,7 @@ class FindPattern extends CasePattern, TFindPattern {
242242
* in List[*init, "a", Integer => x, *tail]
243243
* ```
244244
*/
245-
LocalVariableWriteAccess getSuffix() {
245+
LocalVariableWriteAccess getSuffixVariableAccess() {
246246
toGenerated(result) = max(int i | | g.getChild(i) order by i).(Ruby::SplatParameter).getName()
247247
}
248248

@@ -257,9 +257,9 @@ class FindPattern extends CasePattern, TFindPattern {
257257
or
258258
pred = "getElement" and result = this.getElement(_)
259259
or
260-
pred = "getPrefix" and result = this.getPrefix()
260+
pred = "getPrefixVariableAccess" and result = this.getPrefixVariableAccess()
261261
or
262-
pred = "getSuffix" and result = this.getSuffix()
262+
pred = "getSuffixVariableAccess" and result = this.getSuffixVariableAccess()
263263
}
264264
}
265265

@@ -300,7 +300,7 @@ class HashPattern extends CasePattern, THashPattern {
300300
* in { a: 1, **rest }
301301
* ```
302302
*/
303-
LocalVariableWriteAccess getRestVariable() {
303+
LocalVariableWriteAccess getRestVariableAccess() {
304304
toGenerated(result) =
305305
max(int i | | g.getChild(i) order by i).(Ruby::HashSplatParameter).getName()
306306
}
@@ -309,7 +309,7 @@ class HashPattern extends CasePattern, THashPattern {
309309
* Holds if this pattern is terminated by `**nil` indicating that the pattern does not permit
310310
* any unmatched remaining pairs.
311311
*/
312-
predicate allowUnmatchedElements() { g.getChild(_) instanceof Ruby::HashSplatNil }
312+
predicate allowsUnmatchedElements() { g.getChild(_) instanceof Ruby::HashSplatNil }
313313

314314
final override string getAPrimaryQlClass() { result = "HashPattern" }
315315

@@ -324,7 +324,7 @@ class HashPattern extends CasePattern, THashPattern {
324324
or
325325
pred = "getValue" and result = this.getValue(_)
326326
or
327-
pred = "getRestVariable" and result = this.getRestVariable()
327+
pred = "getRestVariableAccess" and result = this.getRestVariableAccess()
328328
}
329329
}
330330

@@ -371,7 +371,7 @@ class AsPattern extends CasePattern, TAsPattern {
371371
AsPattern() { this = TAsPattern(g) }
372372

373373
/** Gets the underlying pattern. */
374-
CasePattern getValue() { toGenerated(result) = g.getValue() }
374+
CasePattern getPattern() { toGenerated(result) = g.getValue() }
375375

376376
/** Gets the variable access for this pattern. */
377377
LocalVariableWriteAccess getVariableAccess() { toGenerated(result) = g.getName() }
@@ -383,7 +383,7 @@ class AsPattern extends CasePattern, TAsPattern {
383383
final override AstNode getAChild(string pred) {
384384
result = super.getAChild(pred)
385385
or
386-
pred = "getValue" and result = this.getValue()
386+
pred = "getPattern" and result = this.getPattern()
387387
or
388388
pred = "getVariableAccess" and result = this.getVariableAccess()
389389
}
@@ -403,7 +403,7 @@ class VariableReferencePattern extends CasePattern, TVariableReferencePattern {
403403

404404
VariableReferencePattern() { this = TVariableReferencePattern(g) }
405405

406-
/** Gets the variable access correspinging to this variable reference pattern. */
406+
/** Gets the variable access corresponding to this variable reference pattern. */
407407
LocalVariableReadAccess getVariableAccess() { toGenerated(result) = g.getName() }
408408

409409
final override string getAPrimaryQlClass() { result = "VariableReferencePattern" }

ruby/ql/test/library-tests/ast/Ast.expected

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ control/cases.rb:
781781
# 47| getBranch/getInClause: [InClause] in ... then ...
782782
# 47| getPattern: [ArrayPattern] [ ..., * ]
783783
# 47| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
784-
# 47| getRestVariable: [LocalVariableAccess] x
784+
# 47| getRestVariableAccess: [LocalVariableAccess] x
785785
# 47| getSuffixElement: [IntegerLiteral] 3
786786
# 48| getBranch/getInClause: [InClause] in ... then ...
787787
# 48| getPattern: [ArrayPattern] [ ..., * ]
@@ -794,9 +794,9 @@ control/cases.rb:
794794
# 50| getElement: [IntegerLiteral] 3
795795
# 51| getBranch/getInClause: [InClause] in ... then ...
796796
# 51| getPattern: [FindPattern] [ *,...,* ]
797-
# 51| getPrefix: [LocalVariableAccess] a
797+
# 51| getPrefixVariableAccess: [LocalVariableAccess] a
798798
# 51| getElement: [IntegerLiteral] 3
799-
# 51| getSuffix: [LocalVariableAccess] b
799+
# 51| getSuffixVariableAccess: [LocalVariableAccess] b
800800
# 52| getBranch/getInClause: [InClause] in ... then ...
801801
# 52| getPattern: [HashPattern] { ..., ** }
802802
# 52| getKey: [SymbolLiteral] :a
@@ -818,7 +818,7 @@ control/cases.rb:
818818
# 56| getKey: [SymbolLiteral] :a
819819
# 56| getValue: [IntegerLiteral] 5
820820
# 56| getKey: [SymbolLiteral] :b
821-
# 56| getRestVariable: [LocalVariableAccess] map
821+
# 56| getRestVariableAccess: [LocalVariableAccess] map
822822
# 57| getBranch/getInClause: [InClause] in ... then ...
823823
# 57| getPattern: [HashPattern] { ..., ** }
824824
# 57| getKey: [SymbolLiteral] :a
@@ -858,7 +858,7 @@ control/cases.rb:
858858
# 66| getBranch/getInClause: [InClause] in ... then ...
859859
# 66| getPattern: [ArrayPattern] [ ..., * ]
860860
# 66| getPrefixElement/getSuffixElement: [IntegerLiteral] 1
861-
# 66| getRestVariable: [LocalVariableAccess] x
861+
# 66| getRestVariableAccess: [LocalVariableAccess] x
862862
# 66| getSuffixElement: [IntegerLiteral] 3
863863
# 67| getBranch/getInClause: [InClause] in ... then ...
864864
# 67| getPattern: [ArrayPattern] [ ..., * ]
@@ -871,9 +871,9 @@ control/cases.rb:
871871
# 69| getElement: [IntegerLiteral] 3
872872
# 70| getBranch/getInClause: [InClause] in ... then ...
873873
# 70| getPattern: [FindPattern] [ *,...,* ]
874-
# 70| getPrefix: [LocalVariableAccess] a
874+
# 70| getPrefixVariableAccess: [LocalVariableAccess] a
875875
# 70| getElement: [IntegerLiteral] 3
876-
# 70| getSuffix: [LocalVariableAccess] b
876+
# 70| getSuffixVariableAccess: [LocalVariableAccess] b
877877
# 71| getBranch/getInClause: [InClause] in ... then ...
878878
# 71| getPattern: [HashPattern] { ..., ** }
879879
# 71| getKey: [SymbolLiteral] :a
@@ -895,7 +895,7 @@ control/cases.rb:
895895
# 75| getKey: [SymbolLiteral] :a
896896
# 75| getValue: [IntegerLiteral] 5
897897
# 75| getKey: [SymbolLiteral] :b
898-
# 75| getRestVariable: [LocalVariableAccess] map
898+
# 75| getRestVariableAccess: [LocalVariableAccess] map
899899
# 76| getBranch/getInClause: [InClause] in ... then ...
900900
# 76| getPattern: [HashPattern] { ..., ** }
901901
# 76| getKey: [SymbolLiteral] :a
@@ -960,7 +960,7 @@ control/cases.rb:
960960
# 96| getBegin: [IntegerLiteral] 5
961961
# 97| getBranch/getInClause: [InClause] in ... then ...
962962
# 97| getPattern: [AsPattern] ... => ...
963-
# 97| getValue: [IntegerLiteral] 5
963+
# 97| getPattern: [IntegerLiteral] 5
964964
# 97| getVariableAccess: [LocalVariableAccess] x
965965
# 98| getBranch/getInClause: [InClause] in ... then ...
966966
# 98| getPattern: [AlternativePattern] ... | ...
@@ -1031,7 +1031,7 @@ control/cases.rb:
10311031
# 118| getClass: [ConstantReadAccess] Bar
10321032
# 118| getPrefixElement/getSuffixElement: [LocalVariableAccess] a
10331033
# 118| getPrefixElement/getSuffixElement: [LocalVariableAccess] b
1034-
# 118| getRestVariable: [LocalVariableAccess] c
1034+
# 118| getRestVariableAccess: [LocalVariableAccess] c
10351035
# 118| getSuffixElement: [LocalVariableAccess] d
10361036
# 118| getSuffixElement: [LocalVariableAccess] e
10371037
# 123| getStmt: [CaseMatch] case ... in
@@ -1042,10 +1042,10 @@ control/cases.rb:
10421042
# 124| getElement: [LocalVariableAccess] x
10431043
# 125| getBranch/getInClause: [InClause] in ... then ...
10441044
# 125| getPattern: [FindPattern] [ *,...,* ]
1045-
# 125| getPrefix: [LocalVariableAccess] x
1045+
# 125| getPrefixVariableAccess: [LocalVariableAccess] x
10461046
# 125| getElement: [IntegerLiteral] 1
10471047
# 125| getElement: [IntegerLiteral] 2
1048-
# 125| getSuffix: [LocalVariableAccess] y
1048+
# 125| getSuffixVariableAccess: [LocalVariableAccess] y
10491049
# 126| getBranch/getInClause: [InClause] in ... then ...
10501050
# 126| getPattern: [FindPattern] [ *,...,* ]
10511051
# 126| getClass: [ConstantReadAccess] Bar
@@ -1076,7 +1076,7 @@ control/cases.rb:
10761076
# 136| getKey: [SymbolLiteral] :x
10771077
# 136| getValue: [IntegerLiteral] 1
10781078
# 136| getKey: [SymbolLiteral] :a
1079-
# 136| getRestVariable: [LocalVariableAccess] rest
1079+
# 136| getRestVariableAccess: [LocalVariableAccess] rest
10801080
# 137| getBranch/getInClause: [InClause] in ... then ...
10811081
# 137| getPattern: [HashPattern] { ..., ** }
10821082
# 137| getClass: [ConstantReadAccess] Foo

0 commit comments

Comments
 (0)