diff --git a/ruby/ql/lib/codeql/ruby/ast/internal/Variable.qll b/ruby/ql/lib/codeql/ruby/ast/internal/Variable.qll index 3119576a06b..51e5d4b5630 100644 --- a/ruby/ql/lib/codeql/ruby/ast/internal/Variable.qll +++ b/ruby/ql/lib/codeql/ruby/ast/internal/Variable.qll @@ -368,20 +368,8 @@ private module Cached { exists(Scope scope1, CfgScope scope2 | scope1 = access.getVariable().getDeclaringScope() and scope2 = access.getCfgScope() and - scope1 != scope2 - | - if access instanceof SelfVariableAccess - then - // ``` - // class C - // def self.m // not a captured access - // end - // - // self.foo // not a captured access - // end - // ``` - not scope2 instanceof Toplevel - else any() + scope1 != scope2 and + not scope2 instanceof Toplevel ) } diff --git a/ruby/ql/test/library-tests/variables/ssa.expected b/ruby/ql/test/library-tests/variables/ssa.expected index 962cd733a08..0a0c59a322b 100644 --- a/ruby/ql/test/library-tests/variables/ssa.expected +++ b/ruby/ql/test/library-tests/variables/ssa.expected @@ -103,13 +103,9 @@ definition | scopes.rb:26:1:26:12 | self (A) | scopes.rb:26:1:26:12 | self | | scopes.rb:27:1:27:1 | x | scopes.rb:27:1:27:1 | x | | scopes.rb:28:1:30:3 | self (B) | scopes.rb:28:1:30:3 | self | -| scopes.rb:29:3:29:3 | x | scopes.rb:29:3:29:3 | x | -| scopes.rb:32:3:32:3 | x | scopes.rb:32:3:32:3 | x | | scopes.rb:34:1:36:3 | self (C) | scopes.rb:34:1:36:3 | self | -| scopes.rb:35:3:35:3 | x | scopes.rb:35:3:35:3 | x | | scopes.rb:41:1:49:3 | self (M) | scopes.rb:41:1:49:3 | self | | scopes.rb:42:2:42:4 | var | scopes.rb:42:2:42:4 | var | -| scopes.rb:43:2:43:4 | foo | scopes.rb:43:2:43:4 | foo | | scopes.rb:46:5:46:8 | var2 | scopes.rb:46:5:46:8 | var2 | | ssa.rb:1:1:16:3 | self (m) | ssa.rb:1:1:16:3 | self | | ssa.rb:1:7:1:7 | b | ssa.rb:1:7:1:7 | b | diff --git a/ruby/ql/test/library-tests/variables/varaccess.expected b/ruby/ql/test/library-tests/variables/varaccess.expected index cb643bb4233..deead16a654 100644 --- a/ruby/ql/test/library-tests/variables/varaccess.expected +++ b/ruby/ql/test/library-tests/variables/varaccess.expected @@ -619,18 +619,8 @@ readAccess captureAccess | instance_variables.rb:28:3:28:4 | self | | instance_variables.rb:32:12:32:13 | self | -| nested_scopes.rb:5:3:5:3 | a | -| nested_scopes.rb:7:5:7:5 | a | -| nested_scopes.rb:9:7:9:7 | a | -| nested_scopes.rb:11:9:11:9 | a | | nested_scopes.rb:18:29:18:34 | self | | nested_scopes.rb:18:34:18:34 | a | -| nested_scopes.rb:25:14:25:14 | a | -| nested_scopes.rb:31:11:31:11 | a | -| nested_scopes.rb:32:16:32:16 | a | -| nested_scopes.rb:34:12:34:12 | a | -| nested_scopes.rb:36:10:36:10 | a | -| nested_scopes.rb:38:8:38:8 | a | | parameters.rb:3:4:3:9 | self | | parameters.rb:4:4:4:9 | self | | parameters.rb:17:5:17:28 | self | @@ -653,14 +643,6 @@ captureAccess | scopes.rb:15:4:15:9 | self | | scopes.rb:16:4:16:9 | self | | scopes.rb:17:4:17:9 | self | -| scopes.rb:29:3:29:3 | x | -| scopes.rb:32:3:32:3 | x | -| scopes.rb:35:3:35:3 | x | -| scopes.rb:42:2:42:4 | var | -| scopes.rb:43:2:43:4 | foo | -| scopes.rb:44:5:44:7 | var | -| scopes.rb:46:5:46:8 | var2 | -| scopes.rb:47:5:47:8 | var2 | | ssa.rb:26:7:26:10 | elem | | ssa.rb:27:5:27:13 | self | | ssa.rb:27:10:27:13 | elem |