Skip to content

Commit 0bc476f

Browse files
committed
ruby: fix spurious alert
1 parent d621a07 commit 0bc476f

File tree

3 files changed

+2
-2
lines changed

3 files changed

+2
-2
lines changed

Diff for: ruby/ql/src/queries/variables/UninitializedLocal.ql

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class RelevantLocalVariableReadAccess extends LocalVariableReadAccess {
8282
not exists(ConditionalExpr c | factor(c.getCondition(), this.getVariable().getAnAccess()) |
8383
this = c.getBranch(true).getAChild*()
8484
) and
85+
not exists(ConditionalLoop l | factor(l.getCondition(), evaluatingMention(this))) and
8586
not loopProtects(_, this)
8687
}
8788
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
| UninitializedLocal.rb:12:5:12:5 | m | Local variable $@ may be used before it is initialized. | UninitializedLocal.rb:8:9:8:9 | m | m |
22
| UninitializedLocal.rb:17:18:17:18 | a | Local variable $@ may be used before it is initialized. | UninitializedLocal.rb:17:9:17:9 | a | a |
3-
| UninitializedLocal.rb:35:15:35:15 | a | Local variable $@ may be used before it is initialized. | UninitializedLocal.rb:31:13:31:13 | a | a |

Diff for: ruby/ql/test/query-tests/variables/UninitializedLocal/UninitializedLocal.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ def test_loop
3232
else
3333
set_a
3434
end
35-
end until a #$ SPURIOUS: Alert
35+
end until a # OK
3636
a # OK - given previous until
3737
end

0 commit comments

Comments
 (0)