Skip to content

Commit 4644f08

Browse files
committed
Ruby: Routing.qll - rename call as methodCall
1 parent 25f9449 commit 4644f08

File tree

1 file changed

+32
-27
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks/actiondispatch/internal

1 file changed

+32
-27
lines changed

ruby/ql/lib/codeql/ruby/frameworks/actiondispatch/internal/Routing.qll

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ module Routing {
8686
* ```
8787
*/
8888
private class TopLevelRouteBlock extends RouteBlock, TTopLevelRouteBlock {
89-
MethodCall call;
89+
MethodCall methodCall;
9090
// Routing blocks create scopes which define the namespace for controllers and paths,
9191
// though they can be overridden in various ways.
9292
// The namespaces can differ, so we track them separately.
9393
Block block;
9494

95-
TopLevelRouteBlock() { this = TTopLevelRouteBlock(_, call, block) }
95+
TopLevelRouteBlock() { this = TTopLevelRouteBlock(_, methodCall, block) }
9696

9797
override string getAPrimaryQlClass() { result = "TopLevelRouteBlock" }
9898

@@ -102,9 +102,9 @@ module Routing {
102102

103103
override RouteBlock getParent() { none() }
104104

105-
override string toString() { result = call.toString() }
105+
override string toString() { result = methodCall.toString() }
106106

107-
override Location getLocation() { result = call.getLocation() }
107+
override Location getLocation() { result = methodCall.getLocation() }
108108

109109
override string getPathComponent() { none() }
110110

@@ -122,9 +122,9 @@ module Routing {
122122
*/
123123
private class ConstraintsRouteBlock extends NestedRouteBlock, TConstraintsRouteBlock {
124124
private Block block;
125-
private MethodCall call;
125+
private MethodCall methodCall;
126126

127-
ConstraintsRouteBlock() { this = TConstraintsRouteBlock(parent, call, block) }
127+
ConstraintsRouteBlock() { this = TConstraintsRouteBlock(parent, methodCall, block) }
128128

129129
override string getAPrimaryQlClass() { result = "ConstraintsRouteBlock" }
130130

@@ -134,9 +134,9 @@ module Routing {
134134

135135
override string getControllerComponent() { result = "" }
136136

137-
override string toString() { result = call.toString() }
137+
override string toString() { result = methodCall.toString() }
138138

139-
override Location getLocation() { result = call.getLocation() }
139+
override Location getLocation() { result = methodCall.getLocation() }
140140
}
141141

142142
/**
@@ -149,28 +149,31 @@ module Routing {
149149
* https://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Scoping.html#method-i-scope
150150
*/
151151
private class ScopeRouteBlock extends NestedRouteBlock, TScopeRouteBlock {
152-
private MethodCall call;
152+
private MethodCall methodCall;
153153
private Block block;
154154

155-
ScopeRouteBlock() { this = TScopeRouteBlock(parent, call, block) }
155+
ScopeRouteBlock() { this = TScopeRouteBlock(parent, methodCall, block) }
156156

157157
override string getAPrimaryQlClass() { result = "ScopeRouteBlock" }
158158

159159
override Stmt getAStmt() { result = block.getAStmt() }
160160

161-
override string toString() { result = call.toString() }
161+
override string toString() { result = methodCall.toString() }
162162

163-
override Location getLocation() { result = call.getLocation() }
163+
override Location getLocation() { result = methodCall.getLocation() }
164164

165165
override string getPathComponent() {
166-
call.getKeywordArgument("path").getConstantValue().isStringlikeValue(result)
166+
methodCall.getKeywordArgument("path").getConstantValue().isStringlikeValue(result)
167167
or
168-
not exists(call.getKeywordArgument("path")) and
169-
call.getArgument(0).getConstantValue().isStringlikeValue(result)
168+
not exists(methodCall.getKeywordArgument("path")) and
169+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(result)
170170
}
171171

172172
override string getControllerComponent() {
173-
call.getKeywordArgument(["controller", "module"]).getConstantValue().isStringlikeValue(result)
173+
methodCall
174+
.getKeywordArgument(["controller", "module"])
175+
.getConstantValue()
176+
.isStringlikeValue(result)
174177
}
175178
}
176179

@@ -184,10 +187,10 @@ module Routing {
184187
* https://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resources
185188
*/
186189
private class ResourcesRouteBlock extends NestedRouteBlock, TResourcesRouteBlock {
187-
private MethodCall call;
190+
private MethodCall methodCall;
188191
private Block block;
189192

190-
ResourcesRouteBlock() { this = TResourcesRouteBlock(parent, call, block) }
193+
ResourcesRouteBlock() { this = TResourcesRouteBlock(parent, methodCall, block) }
191194

192195
override string getAPrimaryQlClass() { result = "ResourcesRouteBlock" }
193196

@@ -196,19 +199,21 @@ module Routing {
196199
/**
197200
* Gets the `resources` call that gives rise to this route block.
198201
*/
199-
MethodCall getDefiningMethodCall() { result = call }
202+
MethodCall getDefiningMethodCall() { result = methodCall }
200203

201204
override string getPathComponent() {
202-
exists(string resource | call.getArgument(0).getConstantValue().isStringlikeValue(resource) |
205+
exists(string resource |
206+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(resource)
207+
|
203208
result = resource + "/:" + singularize(resource) + "_id"
204209
)
205210
}
206211

207212
override string getControllerComponent() { result = "" }
208213

209-
override string toString() { result = call.toString() }
214+
override string toString() { result = methodCall.toString() }
210215

211-
override Location getLocation() { result = call.getLocation() }
216+
override Location getLocation() { result = methodCall.getLocation() }
212217
}
213218

214219
/**
@@ -250,10 +255,10 @@ module Routing {
250255
* https://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Scoping.html#method-i-namespace
251256
*/
252257
private class NamespaceRouteBlock extends NestedRouteBlock, TNamespaceRouteBlock {
253-
private MethodCall call;
258+
private MethodCall methodCall;
254259
private Block block;
255260

256-
NamespaceRouteBlock() { this = TNamespaceRouteBlock(parent, call, block) }
261+
NamespaceRouteBlock() { this = TNamespaceRouteBlock(parent, methodCall, block) }
257262

258263
override Stmt getAStmt() { result = block.getAStmt() }
259264

@@ -262,12 +267,12 @@ module Routing {
262267
override string getControllerComponent() { result = this.getNamespace() }
263268

264269
private string getNamespace() {
265-
call.getArgument(0).getConstantValue().isStringlikeValue(result)
270+
methodCall.getArgument(0).getConstantValue().isStringlikeValue(result)
266271
}
267272

268-
override string toString() { result = call.toString() }
273+
override string toString() { result = methodCall.toString() }
269274

270-
override Location getLocation() { result = call.getLocation() }
275+
override Location getLocation() { result = methodCall.getLocation() }
271276
}
272277

273278
/**

0 commit comments

Comments
 (0)