Skip to content

Commit 69f1c18

Browse files
authored
Merge pull request #7446 from jeffgran/jg/constant-write-access
[Ruby] Bugfix: ConstantWriteAccess::getQualifiedName() returns wrong value in some cases
2 parents 27f786b + accfd48 commit 69f1c18

File tree

9 files changed

+228
-51
lines changed

9 files changed

+228
-51
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* `ConstantWriteAccess.getQualifiedName()` has been deprecated in favor of `getAQualifiedName()` which can return multiple possible qualified names for a given constant write access.

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class ConstantWriteAccess extends ConstantAccess {
168168
override string getAPrimaryQlClass() { result = "ConstantWriteAccess" }
169169

170170
/**
171-
* Gets the fully qualified name for this constant, based on the context in
171+
* Gets a fully qualified name for this constant, based on the context in
172172
* which it is defined.
173173
*
174174
* For example, given
@@ -184,17 +184,31 @@ class ConstantWriteAccess extends ConstantAccess {
184184
*
185185
* the constant `Baz` has the fully qualified name `Foo::Bar::Baz`, and
186186
* `CONST_A` has the fully qualified name `Foo::CONST_A`.
187+
*
188+
* Important note: This can return more than one value, because there are
189+
* situations where there can be multiple possible "fully qualified" names.
190+
* For example:
191+
* ```
192+
* module Mod4
193+
* include Mod1
194+
* module Mod3::Mod5 end
195+
* end
196+
* ```
197+
* In the above snippet, `Mod5` has two valid fully qualified names it can be
198+
* referred to by: `Mod1::Mod3::Mod5`, or `Mod4::Mod3::Mod5`.
199+
*
200+
* Another example has to do with the order in which module definitions are
201+
* executed at runtime. Because of the way that ruby dynamically looks up
202+
* constants up the namespace chain, the fully qualified name of a nested
203+
* constant can be ambiguous from just statically looking at the AST.
187204
*/
188-
string getQualifiedName() {
189-
/* get the qualified name for the parent module, then append w */
190-
exists(ConstantWriteAccess parent | parent = this.getEnclosingModule() |
191-
result = parent.getQualifiedName() + "::" + this.getName()
192-
)
193-
or
194-
/* base case - there's no parent module */
195-
not exists(ConstantWriteAccess parent | parent = this.getEnclosingModule()) and
196-
result = this.getName()
197-
}
205+
string getAQualifiedName() { result = resolveConstantWriteAccess(this) }
206+
207+
/**
208+
* Gets a qualified name for this constant. Deprecated in favor of
209+
* `getAQualifiedName` because this can return more than one value
210+
*/
211+
deprecated string getQualifiedName() { result = this.getAQualifiedName() }
198212
}
199213

200214
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private class ActiveRecordModelFinderCall extends ActiveRecordModelInstantiation
278278
ActiveRecordModelFinderCall() {
279279
call = this.asExpr().getExpr() and
280280
recv = getUltimateReceiver(call) and
281-
resolveConstant(recv) = cls.getQualifiedName() and
281+
resolveConstant(recv) = cls.getAQualifiedName() and
282282
call.getMethodName() = finderMethodName()
283283
}
284284

ruby/ql/src/queries/analysis/Definitions.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ConstantWriteAccess definitionOf(string fqn) {
7878
fqn = resolveConstant(_) and
7979
result =
8080
min(ConstantWriteAccess w, Location l |
81-
w.getQualifiedName() = fqn and l = w.getLocation()
81+
w.getAQualifiedName() = fqn and l = w.getLocation()
8282
|
8383
w
8484
order by

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

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,24 +1333,76 @@ constants/constants.rb:
13331333
# 31| getScopeExpr: [ConstantReadAccess] ModuleA
13341334
# 31| getSuperclassExpr: [ConstantReadAccess] ClassA
13351335
# 31| getScopeExpr: [ConstantReadAccess] ModuleA
1336-
# 34| getStmt: [ModuleDeclaration] ModuleC
1337-
# 34| getScopeExpr: [ConstantReadAccess] ModuleA
1338-
# 37| getStmt: [AssignExpr] ... = ...
1339-
# 37| getAnOperand/getLeftOperand: [ConstantAssignment] MAX_SIZE
1340-
# 37| getScopeExpr: [ConstantReadAccess] ModuleB
1341-
# 37| getScopeExpr: [ConstantReadAccess] ModuleA
1342-
# 37| getAnOperand/getRightOperand: [IntegerLiteral] 1024
1343-
# 39| getStmt: [MethodCall] call to puts
1344-
# 39| getReceiver: [Self, SelfVariableAccess] self
1345-
# 39| getArgument: [ConstantReadAccess] MAX_SIZE
1336+
# 32| getStmt: [AssignExpr] ... = ...
1337+
# 32| getAnOperand/getLeftOperand: [ConstantAssignment] FOURTY_TWO
1338+
# 32| getAnOperand/getRightOperand: [IntegerLiteral] 42
1339+
# 35| getStmt: [ModuleDeclaration] ModuleC
1340+
# 35| getScopeExpr: [ConstantReadAccess] ModuleA
1341+
# 36| getStmt: [AssignExpr] ... = ...
1342+
# 36| getAnOperand/getLeftOperand: [ConstantAssignment] FOURTY_THREE
1343+
# 36| getAnOperand/getRightOperand: [IntegerLiteral] 43
1344+
# 39| getStmt: [AssignExpr] ... = ...
1345+
# 39| getAnOperand/getLeftOperand: [ConstantAssignment] MAX_SIZE
13461346
# 39| getScopeExpr: [ConstantReadAccess] ModuleB
13471347
# 39| getScopeExpr: [ConstantReadAccess] ModuleA
1348+
# 39| getAnOperand/getRightOperand: [IntegerLiteral] 1024
13481349
# 41| getStmt: [MethodCall] call to puts
13491350
# 41| getReceiver: [Self, SelfVariableAccess] self
1350-
# 41| getArgument: [ConstantReadAccess] GREETING
1351-
# 42| getStmt: [MethodCall] call to puts
1352-
# 42| getReceiver: [Self, SelfVariableAccess] self
1353-
# 42| getArgument: [ConstantReadAccess] GREETING
1351+
# 41| getArgument: [ConstantReadAccess] MAX_SIZE
1352+
# 41| getScopeExpr: [ConstantReadAccess] ModuleB
1353+
# 41| getScopeExpr: [ConstantReadAccess] ModuleA
1354+
# 43| getStmt: [MethodCall] call to puts
1355+
# 43| getReceiver: [Self, SelfVariableAccess] self
1356+
# 43| getArgument: [ConstantReadAccess] GREETING
1357+
# 44| getStmt: [MethodCall] call to puts
1358+
# 44| getReceiver: [Self, SelfVariableAccess] self
1359+
# 44| getArgument: [ConstantReadAccess] GREETING
1360+
# 46| getStmt: [ModuleDeclaration] ModuleB
1361+
# 46| getScopeExpr: [ConstantReadAccess] ModuleA
1362+
# 47| getStmt: [ClassDeclaration] ClassB
1363+
# 47| getSuperclassExpr: [ConstantReadAccess] Base
1364+
# 48| getStmt: [AssignExpr] ... = ...
1365+
# 48| getAnOperand/getLeftOperand: [ConstantAssignment] FOURTY_ONE
1366+
# 48| getAnOperand/getRightOperand: [IntegerLiteral] 41
1367+
# 52| getStmt: [ModuleDeclaration] ModuleA
1368+
# 53| getStmt: [AssignExpr] ... = ...
1369+
# 53| getAnOperand/getLeftOperand: [ConstantAssignment] FOURTY_FOUR
1370+
# 53| getAnOperand/getRightOperand: [StringLiteral] "fourty-four"
1371+
# 53| getComponent: [StringTextComponent] fourty-four
1372+
# 54| getStmt: [ClassDeclaration] ClassB
1373+
# 54| getScopeExpr: [ConstantReadAccess] ModuleB
1374+
# 54| getSuperclassExpr: [ConstantReadAccess] Base
1375+
# 55| getStmt: [AssignExpr] ... = ...
1376+
# 55| getAnOperand/getLeftOperand: [ClassVariableAccess] @@fourty_four
1377+
# 55| getAnOperand/getRightOperand: [ConstantReadAccess] FOURTY_FOUR
1378+
# 56| getStmt: [AssignExpr] ... = ...
1379+
# 56| getAnOperand/getLeftOperand: [ConstantAssignment] FOURTY_FOUR
1380+
# 56| getAnOperand/getRightOperand: [IntegerLiteral] 44
1381+
# 57| getStmt: [AssignExpr] ... = ...
1382+
# 57| getAnOperand/getLeftOperand: [ClassVariableAccess] @@fourty_four
1383+
# 57| getAnOperand/getRightOperand: [ConstantReadAccess] FOURTY_FOUR
1384+
# 61| getStmt: [ModuleDeclaration] Mod1
1385+
# 62| getStmt: [ModuleDeclaration] Mod3
1386+
# 63| getStmt: [AssignExpr] ... = ...
1387+
# 63| getAnOperand/getLeftOperand: [ConstantAssignment] FOURTY_FIVE
1388+
# 63| getAnOperand/getRightOperand: [IntegerLiteral] 45
1389+
# 65| getStmt: [AssignExpr] ... = ...
1390+
# 65| getAnOperand/getLeftOperand: [ClassVariableAccess] @@fourty_five
1391+
# 65| getAnOperand/getRightOperand: [ConstantReadAccess] FOURTY_FIVE
1392+
# 65| getScopeExpr: [ConstantReadAccess] Mod3
1393+
# 68| getStmt: [ModuleDeclaration] Mod4
1394+
# 69| getStmt: [MethodCall] call to include
1395+
# 69| getReceiver: [Self, SelfVariableAccess] self
1396+
# 69| getArgument: [ConstantReadAccess] Mod1
1397+
# 70| getStmt: [ModuleDeclaration] Mod5
1398+
# 70| getScopeExpr: [ConstantReadAccess] Mod3
1399+
# 71| getStmt: [AssignExpr] ... = ...
1400+
# 71| getAnOperand/getLeftOperand: [ConstantAssignment] FOURTY_SIX
1401+
# 71| getAnOperand/getRightOperand: [IntegerLiteral] 46
1402+
# 73| getStmt: [AssignExpr] ... = ...
1403+
# 73| getAnOperand/getLeftOperand: [ClassVariableAccess] @@fourty_six
1404+
# 73| getAnOperand/getRightOperand: [ConstantReadAccess] FOURTY_SIX
1405+
# 73| getScopeExpr: [ConstantReadAccess] Mod3
13541406
literals/literals.rb:
13551407
# 1| [Toplevel] literals.rb
13561408
# 2| getStmt: [NilLiteral] nil

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,20 @@
7474
| constants/constants.rb:20:22:20:28 | "Chuck" | Chuck |
7575
| constants/constants.rb:20:31:20:36 | "Dave" | Dave |
7676
| constants/constants.rb:28:11:28:15 | "foo" | foo |
77-
| constants/constants.rb:37:30:37:33 | 1024 | 1024 |
78-
| constants/constants.rb:39:6:39:31 | MAX_SIZE | 1024 |
77+
| constants/constants.rb:32:16:32:17 | 42 | 42 |
78+
| constants/constants.rb:36:18:36:19 | 43 | 43 |
79+
| constants/constants.rb:39:30:39:33 | 1024 | 1024 |
80+
| constants/constants.rb:41:6:41:31 | MAX_SIZE | 1024 |
81+
| constants/constants.rb:48:18:48:19 | 41 | 41 |
82+
| constants/constants.rb:53:17:53:29 | "fourty-four" | fourty-four |
83+
| constants/constants.rb:55:21:55:31 | FOURTY_FOUR | 44 |
84+
| constants/constants.rb:55:21:55:31 | FOURTY_FOUR | fourty-four |
85+
| constants/constants.rb:56:19:56:20 | 44 | 44 |
86+
| constants/constants.rb:57:21:57:31 | FOURTY_FOUR | 44 |
87+
| constants/constants.rb:57:21:57:31 | FOURTY_FOUR | fourty-four |
88+
| constants/constants.rb:63:19:63:20 | 45 | 45 |
89+
| constants/constants.rb:65:19:65:35 | FOURTY_FIVE | 45 |
90+
| constants/constants.rb:71:18:71:19 | 46 | 46 |
7991
| control/cases.rb:2:5:2:5 | 0 | 0 |
8092
| control/cases.rb:3:5:3:5 | 0 | 0 |
8193
| control/cases.rb:4:5:4:5 | 0 | 0 |

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

Lines changed: 86 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,87 @@ constantAccess
2020
| constants.rb:20:13:20:37 | Array | read | Array | ConstantReadAccess |
2121
| constants.rb:22:5:22:9 | Names | read | Names | ConstantReadAccess |
2222
| constants.rb:23:18:23:25 | GREETING | read | GREETING | ConstantReadAccess |
23-
| constants.rb:31:1:32:3 | ClassD | write | ClassD | ClassDeclaration |
23+
| constants.rb:31:1:33:3 | ClassD | write | ClassD | ClassDeclaration |
2424
| constants.rb:31:7:31:13 | ModuleA | read | ModuleA | ConstantReadAccess |
2525
| constants.rb:31:25:31:31 | ModuleA | read | ModuleA | ConstantReadAccess |
2626
| constants.rb:31:25:31:39 | ClassA | read | ClassA | ConstantReadAccess |
27-
| constants.rb:34:1:35:3 | ModuleC | write | ModuleC | ModuleDeclaration |
28-
| constants.rb:34:8:34:14 | ModuleA | read | ModuleA | ConstantReadAccess |
29-
| constants.rb:37:1:37:7 | ModuleA | read | ModuleA | ConstantReadAccess |
30-
| constants.rb:37:1:37:16 | ModuleB | read | ModuleB | ConstantReadAccess |
31-
| constants.rb:37:1:37:26 | MAX_SIZE | write | MAX_SIZE | ConstantAssignment |
32-
| constants.rb:39:6:39:12 | ModuleA | read | ModuleA | ConstantReadAccess |
33-
| constants.rb:39:6:39:21 | ModuleB | read | ModuleB | ConstantReadAccess |
34-
| constants.rb:39:6:39:31 | MAX_SIZE | read | MAX_SIZE | ConstantReadAccess |
35-
| constants.rb:41:6:41:13 | GREETING | read | GREETING | ConstantReadAccess |
36-
| constants.rb:42:6:42:15 | GREETING | read | GREETING | ConstantReadAccess |
27+
| constants.rb:32:3:32:12 | FOURTY_TWO | write | FOURTY_TWO | ConstantAssignment |
28+
| constants.rb:35:1:37:3 | ModuleC | write | ModuleC | ModuleDeclaration |
29+
| constants.rb:35:8:35:14 | ModuleA | read | ModuleA | ConstantReadAccess |
30+
| constants.rb:36:3:36:14 | FOURTY_THREE | write | FOURTY_THREE | ConstantAssignment |
31+
| constants.rb:39:1:39:7 | ModuleA | read | ModuleA | ConstantReadAccess |
32+
| constants.rb:39:1:39:16 | ModuleB | read | ModuleB | ConstantReadAccess |
33+
| constants.rb:39:1:39:26 | MAX_SIZE | write | MAX_SIZE | ConstantAssignment |
34+
| constants.rb:41:6:41:12 | ModuleA | read | ModuleA | ConstantReadAccess |
35+
| constants.rb:41:6:41:21 | ModuleB | read | ModuleB | ConstantReadAccess |
36+
| constants.rb:41:6:41:31 | MAX_SIZE | read | MAX_SIZE | ConstantReadAccess |
37+
| constants.rb:43:6:43:13 | GREETING | read | GREETING | ConstantReadAccess |
38+
| constants.rb:44:6:44:15 | GREETING | read | GREETING | ConstantReadAccess |
39+
| constants.rb:46:1:50:3 | ModuleB | write | ModuleB | ModuleDeclaration |
40+
| constants.rb:46:8:46:14 | ModuleA | read | ModuleA | ConstantReadAccess |
41+
| constants.rb:47:3:49:5 | ClassB | write | ClassB | ClassDeclaration |
42+
| constants.rb:47:18:47:21 | Base | read | Base | ConstantReadAccess |
43+
| constants.rb:48:5:48:14 | FOURTY_ONE | write | FOURTY_ONE | ConstantAssignment |
44+
| constants.rb:52:1:59:3 | ModuleA | write | ModuleA | ModuleDeclaration |
45+
| constants.rb:53:3:53:13 | FOURTY_FOUR | write | FOURTY_FOUR | ConstantAssignment |
46+
| constants.rb:54:3:58:5 | ClassB | write | ClassB | ClassDeclaration |
47+
| constants.rb:54:9:54:15 | ModuleB | read | ModuleB | ConstantReadAccess |
48+
| constants.rb:54:27:54:30 | Base | read | Base | ConstantReadAccess |
49+
| constants.rb:55:21:55:31 | FOURTY_FOUR | read | FOURTY_FOUR | ConstantReadAccess |
50+
| constants.rb:56:5:56:15 | FOURTY_FOUR | write | FOURTY_FOUR | ConstantAssignment |
51+
| constants.rb:57:21:57:31 | FOURTY_FOUR | read | FOURTY_FOUR | ConstantReadAccess |
52+
| constants.rb:61:1:66:3 | Mod1 | write | Mod1 | ModuleDeclaration |
53+
| constants.rb:62:3:64:5 | Mod3 | write | Mod3 | ModuleDeclaration |
54+
| constants.rb:63:5:63:15 | FOURTY_FIVE | write | FOURTY_FIVE | ConstantAssignment |
55+
| constants.rb:65:19:65:22 | Mod3 | read | Mod3 | ConstantReadAccess |
56+
| constants.rb:65:19:65:35 | FOURTY_FIVE | read | FOURTY_FIVE | ConstantReadAccess |
57+
| constants.rb:68:1:74:3 | Mod4 | write | Mod4 | ModuleDeclaration |
58+
| constants.rb:69:11:69:14 | Mod1 | read | Mod1 | ConstantReadAccess |
59+
| constants.rb:70:3:72:5 | Mod5 | write | Mod5 | ModuleDeclaration |
60+
| constants.rb:70:10:70:13 | Mod3 | read | Mod3 | ConstantReadAccess |
61+
| constants.rb:71:5:71:14 | FOURTY_SIX | write | FOURTY_SIX | ConstantAssignment |
62+
| constants.rb:73:18:73:21 | Mod3 | read | Mod3 | ConstantReadAccess |
63+
| constants.rb:73:18:73:33 | FOURTY_SIX | read | FOURTY_SIX | ConstantReadAccess |
3764
getConst
3865
| constants.rb:1:1:15:3 | ModuleA | CONST_B | constants.rb:6:15:6:23 | "const_b" |
66+
| constants.rb:1:1:15:3 | ModuleA | FOURTY_FOUR | constants.rb:53:17:53:29 | "fourty-four" |
3967
| constants.rb:2:5:4:7 | ModuleA::ClassA | CONST_A | constants.rb:3:19:3:27 | "const_a" |
68+
| constants.rb:31:1:33:3 | ModuleA::ClassD | FOURTY_TWO | constants.rb:32:16:32:17 | 42 |
69+
| constants.rb:35:1:37:3 | ModuleA::ModuleC | FOURTY_THREE | constants.rb:36:18:36:19 | 43 |
70+
| constants.rb:54:3:58:5 | ModuleA::ModuleB::ClassB | FOURTY_FOUR | constants.rb:56:19:56:20 | 44 |
71+
| constants.rb:54:3:58:5 | ModuleA::ModuleB::ClassB | FOURTY_ONE | constants.rb:48:18:48:19 | 41 |
72+
| constants.rb:62:3:64:5 | Mod1::Mod3 | FOURTY_FIVE | constants.rb:63:19:63:20 | 45 |
73+
| constants.rb:70:3:72:5 | Mod1::Mod3::Mod5 | FOURTY_SIX | constants.rb:71:18:71:19 | 46 |
4074
| file://:0:0:0:0 | Object | GREETING | constants.rb:17:12:17:64 | ... + ... |
4175
lookupConst
4276
| constants.rb:1:1:15:3 | ModuleA | CONST_B | constants.rb:6:15:6:23 | "const_b" |
77+
| constants.rb:1:1:15:3 | ModuleA | FOURTY_FOUR | constants.rb:53:17:53:29 | "fourty-four" |
4378
| constants.rb:2:5:4:7 | ModuleA::ClassA | CONST_A | constants.rb:3:19:3:27 | "const_a" |
4479
| constants.rb:2:5:4:7 | ModuleA::ClassA | GREETING | constants.rb:17:12:17:64 | ... + ... |
45-
| constants.rb:8:5:14:7 | ModuleA::ModuleB | MAX_SIZE | constants.rb:37:30:37:33 | 1024 |
46-
| constants.rb:9:9:10:11 | ModuleA::ModuleB::ClassB | GREETING | constants.rb:17:12:17:64 | ... + ... |
80+
| constants.rb:8:5:14:7 | ModuleA::ModuleB | MAX_SIZE | constants.rb:39:30:39:33 | 1024 |
4781
| constants.rb:12:9:13:11 | ModuleA::ModuleB::ClassC | GREETING | constants.rb:17:12:17:64 | ... + ... |
48-
| constants.rb:31:1:32:3 | ModuleA::ClassD | CONST_A | constants.rb:3:19:3:27 | "const_a" |
49-
| constants.rb:31:1:32:3 | ModuleA::ClassD | GREETING | constants.rb:17:12:17:64 | ... + ... |
82+
| constants.rb:31:1:33:3 | ModuleA::ClassD | CONST_A | constants.rb:3:19:3:27 | "const_a" |
83+
| constants.rb:31:1:33:3 | ModuleA::ClassD | FOURTY_TWO | constants.rb:32:16:32:17 | 42 |
84+
| constants.rb:31:1:33:3 | ModuleA::ClassD | GREETING | constants.rb:17:12:17:64 | ... + ... |
85+
| constants.rb:35:1:37:3 | ModuleA::ModuleC | FOURTY_THREE | constants.rb:36:18:36:19 | 43 |
86+
| constants.rb:54:3:58:5 | ModuleA::ModuleB::ClassB | FOURTY_FOUR | constants.rb:56:19:56:20 | 44 |
87+
| constants.rb:54:3:58:5 | ModuleA::ModuleB::ClassB | FOURTY_ONE | constants.rb:48:18:48:19 | 41 |
88+
| constants.rb:54:3:58:5 | ModuleA::ModuleB::ClassB | GREETING | constants.rb:17:12:17:64 | ... + ... |
89+
| constants.rb:62:3:64:5 | Mod1::Mod3 | FOURTY_FIVE | constants.rb:63:19:63:20 | 45 |
90+
| constants.rb:70:3:72:5 | Mod1::Mod3::Mod5 | FOURTY_SIX | constants.rb:71:18:71:19 | 46 |
5091
| file://:0:0:0:0 | Object | GREETING | constants.rb:17:12:17:64 | ... + ... |
5192
constantValue
5293
| constants.rb:17:22:17:45 | CONST_A | constants.rb:3:19:3:27 | "const_a" |
5394
| constants.rb:17:49:17:64 | CONST_B | constants.rb:6:15:6:23 | "const_b" |
5495
| constants.rb:23:18:23:25 | GREETING | constants.rb:17:12:17:64 | ... + ... |
55-
| constants.rb:39:6:39:31 | MAX_SIZE | constants.rb:37:30:37:33 | 1024 |
56-
| constants.rb:41:6:41:13 | GREETING | constants.rb:17:12:17:64 | ... + ... |
57-
| constants.rb:42:6:42:15 | GREETING | constants.rb:17:12:17:64 | ... + ... |
96+
| constants.rb:41:6:41:31 | MAX_SIZE | constants.rb:39:30:39:33 | 1024 |
97+
| constants.rb:43:6:43:13 | GREETING | constants.rb:17:12:17:64 | ... + ... |
98+
| constants.rb:44:6:44:15 | GREETING | constants.rb:17:12:17:64 | ... + ... |
99+
| constants.rb:55:21:55:31 | FOURTY_FOUR | constants.rb:53:17:53:29 | "fourty-four" |
100+
| constants.rb:55:21:55:31 | FOURTY_FOUR | constants.rb:56:19:56:20 | 44 |
101+
| constants.rb:57:21:57:31 | FOURTY_FOUR | constants.rb:53:17:53:29 | "fourty-four" |
102+
| constants.rb:57:21:57:31 | FOURTY_FOUR | constants.rb:56:19:56:20 | 44 |
103+
| constants.rb:65:19:65:35 | FOURTY_FIVE | constants.rb:63:19:63:20 | 45 |
58104
constantWriteAccessQualifiedName
59105
| constants.rb:1:1:15:3 | ModuleA | ModuleA |
60106
| constants.rb:2:5:4:7 | ClassA | ModuleA::ClassA |
@@ -65,6 +111,25 @@ constantWriteAccessQualifiedName
65111
| constants.rb:12:9:13:11 | ClassC | ModuleA::ModuleB::ClassC |
66112
| constants.rb:17:1:17:8 | GREETING | GREETING |
67113
| constants.rb:20:5:20:9 | Names | Names |
68-
| constants.rb:31:1:32:3 | ClassD | ClassD |
69-
| constants.rb:34:1:35:3 | ModuleC | ModuleC |
70-
| constants.rb:37:1:37:26 | MAX_SIZE | MAX_SIZE |
114+
| constants.rb:31:1:33:3 | ClassD | ModuleA::ClassD |
115+
| constants.rb:32:3:32:12 | FOURTY_TWO | ModuleA::ClassD::FOURTY_TWO |
116+
| constants.rb:35:1:37:3 | ModuleC | ModuleA::ModuleC |
117+
| constants.rb:36:3:36:14 | FOURTY_THREE | ModuleA::ModuleC::FOURTY_THREE |
118+
| constants.rb:39:1:39:26 | MAX_SIZE | ModuleA::ModuleB::MAX_SIZE |
119+
| constants.rb:46:1:50:3 | ModuleB | ModuleA::ModuleB |
120+
| constants.rb:47:3:49:5 | ClassB | ModuleA::ModuleB::ClassB |
121+
| constants.rb:48:5:48:14 | FOURTY_ONE | ModuleA::ModuleB::ClassB::FOURTY_ONE |
122+
| constants.rb:52:1:59:3 | ModuleA | ModuleA |
123+
| constants.rb:53:3:53:13 | FOURTY_FOUR | ModuleA::FOURTY_FOUR |
124+
| constants.rb:54:3:58:5 | ClassB | ModuleA::ModuleB::ClassB |
125+
| constants.rb:54:3:58:5 | ClassB | ModuleB::ClassB |
126+
| constants.rb:56:5:56:15 | FOURTY_FOUR | ModuleA::ModuleB::ClassB::FOURTY_FOUR |
127+
| constants.rb:56:5:56:15 | FOURTY_FOUR | ModuleB::ClassB::FOURTY_FOUR |
128+
| constants.rb:61:1:66:3 | Mod1 | Mod1 |
129+
| constants.rb:62:3:64:5 | Mod3 | Mod1::Mod3 |
130+
| constants.rb:63:5:63:15 | FOURTY_FIVE | Mod1::Mod3::FOURTY_FIVE |
131+
| constants.rb:68:1:74:3 | Mod4 | Mod4 |
132+
| constants.rb:70:3:72:5 | Mod5 | Mod1::Mod3::Mod5 |
133+
| constants.rb:70:3:72:5 | Mod5 | Mod3::Mod5 |
134+
| constants.rb:71:5:71:14 | FOURTY_SIX | Mod1::Mod3::Mod5::FOURTY_SIX |
135+
| constants.rb:71:5:71:14 | FOURTY_SIX | Mod3::Mod5::FOURTY_SIX |

ruby/ql/test/library-tests/ast/constants/constants.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ query Expr lookupConst(Module m, string name) { result = M::lookupConst(m, name)
1818
query predicate constantValue(ConstantReadAccess a, Expr e) { e = a.getValue() }
1919

2020
query predicate constantWriteAccessQualifiedName(ConstantWriteAccess w, string qualifiedName) {
21-
w.getQualifiedName() = qualifiedName
21+
w.getAQualifiedName() = qualifiedName
2222
}

0 commit comments

Comments
 (0)