Skip to content

Commit 4ccf9bf

Browse files
committed
Address review comments
1 parent e882cda commit 4ccf9bf

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class IfExpr extends ConditionalExpr, TIfExpr {
102102
cond = false and result = this.getElse()
103103
}
104104

105-
override AstNode getAChild(string pred) {
105+
final override AstNode getAChild(string pred) {
106106
result = super.getAChild(pred)
107107
or
108108
pred = "getThen" and result = this.getThen()
@@ -192,8 +192,8 @@ class UnlessExpr extends ConditionalExpr, TUnlessExpr {
192192

193193
final override string toString() { result = "unless ..." }
194194

195-
override AstNode getAChild(string pred) {
196-
result = ConditionalExpr.super.getAChild(pred)
195+
final override AstNode getAChild(string pred) {
196+
result = super.getAChild(pred)
197197
or
198198
pred = "getThen" and result = this.getThen()
199199
or
@@ -229,8 +229,8 @@ class IfModifierExpr extends ConditionalExpr, TIfModifierExpr {
229229

230230
final override string toString() { result = "... if ..." }
231231

232-
override AstNode getAChild(string pred) {
233-
result = ConditionalExpr.super.getAChild(pred)
232+
final override AstNode getAChild(string pred) {
233+
result = super.getAChild(pred)
234234
or
235235
pred = "getBody" and result = this.getBody()
236236
}
@@ -264,8 +264,8 @@ class UnlessModifierExpr extends ConditionalExpr, TUnlessModifierExpr {
264264

265265
final override string toString() { result = "... unless ..." }
266266

267-
override AstNode getAChild(string pred) {
268-
result = ConditionalExpr.super.getAChild(pred)
267+
final override AstNode getAChild(string pred) {
268+
result = super.getAChild(pred)
269269
or
270270
pred = "getBody" and result = this.getBody()
271271
}
@@ -300,8 +300,8 @@ class TernaryIfExpr extends ConditionalExpr, TTernaryIfExpr {
300300

301301
final override string toString() { result = "... ? ... : ..." }
302302

303-
override AstNode getAChild(string pred) {
304-
result = ConditionalExpr.super.getAChild(pred)
303+
final override AstNode getAChild(string pred) {
304+
result = super.getAChild(pred)
305305
or
306306
pred = "getThen" and result = this.getThen()
307307
or
@@ -390,7 +390,7 @@ class CaseExpr extends ControlExpr instanceof CaseExprImpl {
390390

391391
final override string toString() { result = "case ..." }
392392

393-
override AstNode getAChild(string pred) {
393+
final override AstNode getAChild(string pred) {
394394
result = ControlExpr.super.getAChild(pred)
395395
or
396396
pred = "getValue" and result = this.getValue()
@@ -444,7 +444,7 @@ class WhenExpr extends Expr, TWhenExpr {
444444

445445
final override string toString() { result = "when ..." }
446446

447-
override AstNode getAChild(string pred) {
447+
final override AstNode getAChild(string pred) {
448448
result = super.getAChild(pred)
449449
or
450450
pred = "getBody" and result = this.getBody()
@@ -517,7 +517,7 @@ class InClause extends Expr, TInClause {
517517

518518
final override string toString() { result = "in ... then ..." }
519519

520-
override AstNode getAChild(string pred) {
520+
final override AstNode getAChild(string pred) {
521521
result = super.getAChild(pred)
522522
or
523523
pred = "getBody" and result = this.getBody()
@@ -552,7 +552,7 @@ class ConditionalLoop extends Loop, TConditionalLoop {
552552
Expr getCondition() { none() }
553553

554554
override AstNode getAChild(string pred) {
555-
result = Loop.super.getAChild(pred)
555+
result = super.getAChild(pred)
556556
or
557557
pred = "getCondition" and result = this.getCondition()
558558
}
@@ -707,8 +707,8 @@ class ForExpr extends Loop, TForExpr {
707707

708708
final override string toString() { result = "for ... in ..." }
709709

710-
override AstNode getAChild(string pred) {
711-
result = Loop.super.getAChild(pred)
710+
final override AstNode getAChild(string pred) {
711+
result = super.getAChild(pred)
712712
or
713713
pred = "getPattern" and result = this.getPattern()
714714
or

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ class DestructuredLhsExpr extends LhsExpr, TDestructuredLhsExpr {
140140

141141
override string toString() { result = "(..., ...)" }
142142

143-
override AstNode getAChild(string pred) { pred = "getElement" and result = this.getElement(_) }
143+
final override AstNode getAChild(string pred) {
144+
result = super.getAChild(pred)
145+
or
146+
pred = "getElement" and result = this.getElement(_)
147+
}
144148
}
145149

146150
/** A sequence of expressions. */
@@ -213,7 +217,7 @@ class BodyStmt extends StmtSequence, TBodyStmt {
213217
final predicate hasEnsure() { exists(this.getEnsure()) }
214218

215219
override AstNode getAChild(string pred) {
216-
result = StmtSequence.super.getAChild(pred)
220+
result = super.getAChild(pred)
217221
or
218222
pred = "getRescue" and result = this.getRescue(_)
219223
or
@@ -291,7 +295,7 @@ class Pair extends Expr, TPair {
291295

292296
final override string toString() { result = "Pair" }
293297

294-
override AstNode getAChild(string pred) {
298+
final override AstNode getAChild(string pred) {
295299
result = super.getAChild(pred)
296300
or
297301
pred = "getKey" and result = this.getKey()
@@ -360,7 +364,7 @@ class RescueClause extends Expr, TRescueClause {
360364

361365
final override string toString() { result = "rescue ..." }
362366

363-
override AstNode getAChild(string pred) {
367+
final override AstNode getAChild(string pred) {
364368
result = super.getAChild(pred)
365369
or
366370
pred = "getException" and result = this.getException(_)
@@ -402,7 +406,7 @@ class RescueModifierExpr extends Expr, TRescueModifierExpr {
402406

403407
final override string toString() { result = "... rescue ..." }
404408

405-
override AstNode getAChild(string pred) {
409+
final override AstNode getAChild(string pred) {
406410
result = super.getAChild(pred)
407411
or
408412
pred = "getBody" and result = this.getBody()
@@ -463,7 +467,7 @@ class StringConcatenation extends Expr, TStringConcatenation {
463467

464468
final override string toString() { result = "\"...\" \"...\"" }
465469

466-
override AstNode getAChild(string pred) {
470+
final override AstNode getAChild(string pred) {
467471
result = super.getAChild(pred)
468472
or
469473
pred = "getString" and result = this.getString(_)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ class Assignment extends Operation instanceof AssignmentImpl {
450450

451451
final override string toString() { result = "... " + this.getOperator() + " ..." }
452452

453-
override AstNode getAChild(string pred) {
453+
final override AstNode getAChild(string pred) {
454454
result = Operation.super.getAChild(pred)
455455
or
456456
pred = "getLeftOperand" and result = this.getLeftOperand()

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ class DestructuredParameter extends Parameter, TDestructuredParameter {
5959

6060
override string toString() { result = "(..., ...)" }
6161

62-
override AstNode getAChild(string pred) { pred = "getElement" and result = this.getElement(_) }
62+
final override AstNode getAChild(string pred) {
63+
result = super.getAChild(pred)
64+
or
65+
pred = "getElement" and result = this.getElement(_)
66+
}
6367

6468
final override string getAPrimaryQlClass() { result = "DestructuredParameter" }
6569
}

ruby/ql/lib/codeql/ruby/ast/internal/AST.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ private module Cached {
321321
TBraceBlockReal or TBreakStmt or TCaseEqExpr or TCaseExpr or TCaseMatch or
322322
TCharacterLiteral or TClassDeclaration or TClassVariableAccessReal or TComplementExpr or
323323
TComplexLiteral or TDefinedExpr or TDelimitedSymbolLiteral or TDestructuredLeftAssignment or
324-
TDivExprReal or TDo or TDoBlock or TElementReference or TElse or TElsif or TEmptyStmt or
325-
TEncoding or TEndBlock or TEnsure or TEqExpr or TExponentExprReal or TFalseLiteral or
326-
TFile or TFindPattern or TFloatLiteral or TForExpr or TForwardParameter or
324+
TDestructuredParameter or TDivExprReal or TDo or TDoBlock or TElementReference or TElse or
325+
TElsif or TEmptyStmt or TEncoding or TEndBlock or TEnsure or TEqExpr or TExponentExprReal or
326+
TFalseLiteral or TFile or TFindPattern or TFloatLiteral or TForExpr or TForwardParameter or
327327
TForwardArgument or TGEExpr or TGTExpr or TGlobalVariableAccessReal or
328328
THashKeySymbolLiteral or THashLiteral or THashPattern or THashSplatExpr or
329329
THashSplatNilParameter or THashSplatParameter or THereDoc or TIdentifierMethodCall or TIf or
@@ -342,8 +342,8 @@ private module Cached {
342342
TStringConcatenation or TStringEscapeSequenceComponent or TStringInterpolationComponent or
343343
TStringTextComponent or TSubExprReal or TSubshellLiteral or TSymbolArrayLiteral or
344344
TTernaryIfExpr or TThen or TTokenConstantAccess or TTokenMethodName or TTokenSuperCall or
345-
TToplevel or TTrueLiteral or TDestructuredParameter or TUnaryMinusExpr or TUnaryPlusExpr or
346-
TUndefStmt or TUnlessExpr or TUnlessModifierExpr or TUntilExpr or TUntilModifierExpr or
345+
TToplevel or TTrueLiteral or TUnaryMinusExpr or TUnaryPlusExpr or TUndefStmt or
346+
TUnlessExpr or TUnlessModifierExpr or TUntilExpr or TUntilModifierExpr or
347347
TVariableReferencePattern or TWhenExpr or TWhileExpr or TWhileModifierExpr or TYieldCall;
348348

349349
class TAstNodeSynth =

0 commit comments

Comments
 (0)