Skip to content

Commit 271de66

Browse files
committed
Ruby: rename getConst -> getConstant
1 parent a75c506 commit 271de66

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ private module Cached {
381381
predicate forceCachingInSameStage() { any() }
382382

383383
cached
384-
predicate forceCachingBackref() { exists(any(ConstRef const).getConst(_)) }
384+
predicate forceCachingBackref() { exists(any(ConstRef const).getConstant(_)) }
385385
}
386386

387387
private import Cached
@@ -1135,7 +1135,7 @@ class ArrayLiteralNode extends LocalSourceNode, ExprNode {
11351135
/**
11361136
* An access to a constant, such as `C`, `C::D`, or a class or module declaration.
11371137
*
1138-
* See `DataFlow::getConst` for usage example.
1138+
* See `DataFlow::getConstant` for usage example.
11391139
*/
11401140
class ConstRef extends LocalSourceNode {
11411141
private ConstantAccess access;
@@ -1215,7 +1215,7 @@ class ConstRef extends LocalSourceNode {
12151215
* Gets the scope expression, or the immediately enclosing `Namespace` (skipping over singleton classes).
12161216
*
12171217
* Top-levels are not included, since this is only needed for nested constant lookup, and unqualified constants
1218-
* at the top-level are handled by `DataFlow::getConst`, never `ConstRef.getConst`.
1218+
* at the top-level are handled by `DataFlow::getConstant`, never `ConstRef.getConstant`.
12191219
*/
12201220
private TConstLookupScope getLookupScope() {
12211221
result = MkQualifiedLookup(access.getScopeExpr())
@@ -1248,7 +1248,7 @@ class ConstRef extends LocalSourceNode {
12481248
/**
12491249
* Gets a constant reference that may resolve to a member of this node.
12501250
*
1251-
* For example `DataFlow::getConst("A").getConst("B")` finds the following:
1251+
* For example `DataFlow::getConstant("A").getConstant("B")` finds the following:
12521252
* ```rb
12531253
* A::B # simple reference
12541254
*
@@ -1270,7 +1270,7 @@ class ConstRef extends LocalSourceNode {
12701270
* ```
12711271
*/
12721272
pragma[inline]
1273-
ConstRef getConst(string name) {
1273+
ConstRef getConstant(string name) {
12741274
exists(TConstLookupScope scope |
12751275
pragma[only_bind_into](scope) = pragma[only_bind_out](this).getATargetScope() and
12761276
result.accesses(pragma[only_bind_out](scope), name)
@@ -1281,7 +1281,7 @@ class ConstRef extends LocalSourceNode {
12811281
* Gets a module that transitively subclasses, includes, or prepends the module referred to by
12821282
* this constant.
12831283
*
1284-
* For example, `DataFlow::getConst("A").getADescendentModule()` finds `B`, `C`, and `E`:
1284+
* For example, `DataFlow::getConstant("A").getADescendentModule()` finds `B`, `C`, and `E`:
12851285
* ```rb
12861286
* class B < A
12871287
* end
@@ -1300,9 +1300,9 @@ class ConstRef extends LocalSourceNode {
13001300
/**
13011301
* Gets a constant reference that may resolve to the top-level constant `name`.
13021302
*
1303-
* To get nested constants, call `getConst()` one or more times on the result.
1303+
* To get nested constants, call `getConstant()` one or more times on the result.
13041304
*
1305-
* For example `DataFlow::getConst("A").getConst("B")` finds the following:
1305+
* For example `DataFlow::getConstant("A").getConstant("B")` finds the following:
13061306
* ```rb
13071307
* A::B # simple reference
13081308
*
@@ -1324,7 +1324,7 @@ class ConstRef extends LocalSourceNode {
13241324
* ```
13251325
*/
13261326
pragma[nomagic]
1327-
ConstRef getConst(string name) {
1327+
ConstRef getConstant(string name) {
13281328
result.getName() = name and
13291329
result.isPossiblyGlobal()
13301330
}

ruby/ql/lib/codeql/ruby/frameworks/ActionController.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ class ActionControllerClass extends DataFlow::ClassNode {
4040
ActionControllerClass() {
4141
this =
4242
[
43-
DataFlow::getConst("ActionController").getConst("Base"),
43+
DataFlow::getConstant("ActionController").getConstant("Base"),
4444
// In Rails applications `ApplicationController` typically extends `ActionController::Base`, but we
4545
// treat it separately in case the `ApplicationController` definition is not in the database.
46-
DataFlow::getConst("ApplicationController"),
46+
DataFlow::getConstant("ApplicationController"),
4747
// ActionController::Metal technically doesn't contain all of the
4848
// methods available in Base, such as those for rendering views.
4949
// However we prefer to be over-sensitive in this case in order to find
5050
// more results.
51-
DataFlow::getConst("ActionController").getConst("Metal")
51+
DataFlow::getConstant("ActionController").getConstant("Metal")
5252
].getADescendentModule()
5353
}
5454

ruby/ql/lib/codeql/ruby/frameworks/Rails.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ module Rails {
9494
/**
9595
* Gets a reference to the `Rails` constant.
9696
*/
97-
private DataFlow::ConstRef rails() { result = DataFlow::getConst("Rails") }
97+
private DataFlow::ConstRef rails() { result = DataFlow::getConstant("Rails") }
9898

9999
/**
100100
* Gets a reference to either `Rails::Railtie`, `Rails::Engine`, or `Rails::Application`.
101101
* `Engine` and `Application` extend `Railtie`, but may not have definitions present in the database.
102102
*/
103103
private DataFlow::ConstRef railtie() {
104-
result = rails().getConst(["Railtie", "Engine", "Application"])
104+
result = rails().getConstant(["Railtie", "Engine", "Application"])
105105
}
106106

107107
/** Gets a class that transitively extends `Rails::Railtie` */
@@ -113,7 +113,7 @@ private DataFlow::ClassNode railtieClass() { result = railtie().getADescendentMo
113113
private DataFlow::LocalSourceNode railsApp() {
114114
result = rails().getAMethodCall("application")
115115
or
116-
result = rails().getConst("Application")
116+
result = rails().getConstant("Application")
117117
}
118118

119119
/**

ruby/ql/lib/codeql/ruby/frameworks/Railties.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private import codeql.ruby.DataFlow
1313
*/
1414
module Railties {
1515
private DataFlow::ConstRef generatorsActionsConst() {
16-
result = DataFlow::getConst("Rails").getConst("Generators").getConst("Actions")
16+
result = DataFlow::getConstant("Rails").getConstant("Generators").getConstant("Actions")
1717
}
1818

1919
/**

ruby/ql/test/library-tests/dataflow/helpers/dataflow.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ getTopLevelConst
210210
| XY2 | tst.rb:44:9:45:11 | self (XY2) |
211211
| XY3 | tst.rb:53:5:54:7 | self (XY3) |
212212
| Y | tst.rb:53:17:53:17 | Y |
213-
getConst
213+
getConstant
214214
| tst.rb:41:17:41:17 | X | Y | tst.rb:41:17:41:20 | Y |
215215
| tst.rb:44:21:44:21 | X | Y | tst.rb:44:21:44:24 | Y |
216216
| tst.rb:50:13:50:13 | X | X | tst.rb:50:13:50:13 | X |

ruby/ql/test/library-tests/dataflow/helpers/dataflow.ql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ query DataFlow::ModuleNode getNestedModule(DataFlow::ModuleNode mod, string name
5050
result = mod.getNestedModule(name)
5151
}
5252

53-
query DataFlow::Node getTopLevelConst(string name) { result = DataFlow::getConst(name) }
53+
query DataFlow::Node getTopLevelConst(string name) { result = DataFlow::getConstant(name) }
5454

55-
query DataFlow::Node getConst(DataFlow::ConstRef base, string name) { result = base.getConst(name) }
55+
query DataFlow::Node getConstant(DataFlow::ConstRef base, string name) {
56+
result = base.getConstant(name)
57+
}
5658

5759
query DataFlow::ModuleNode getXYClasses() {
58-
result = DataFlow::getConst("X").getConst("Y").getADescendentModule()
60+
result = DataFlow::getConstant("X").getConstant("Y").getADescendentModule()
5961
}
6062

6163
query DataFlow::HashLiteralNode hashLiteralNode() { any() }

0 commit comments

Comments
 (0)