mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
ruby: test for DeadStore and captured variables
This commit is contained in:
@@ -1 +1,2 @@
|
||||
| DeadStoreOfLocal.rb:2:5:2:5 | y | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.rb:2:5:2:5 | y | y |
|
||||
| DeadStoreOfLocal.rb:61:17:61:17 | x | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.rb:56:17:56:17 | x | x |
|
||||
|
||||
@@ -33,4 +33,34 @@ class Sub < Sup
|
||||
y = 3 # OK - the call to `super` sees the value of `y``
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def do_twice
|
||||
yield
|
||||
yield
|
||||
end
|
||||
|
||||
def get_done_twice x
|
||||
do_twice do
|
||||
print x
|
||||
x += 1 # OK - the block is executed twice
|
||||
end
|
||||
end
|
||||
|
||||
def retry_once
|
||||
yield
|
||||
rescue
|
||||
yield
|
||||
end
|
||||
|
||||
def get_retried x
|
||||
retry_once do
|
||||
print x
|
||||
if x < 1
|
||||
begin
|
||||
x += 1 #$ SPURIOUS: Alert
|
||||
raise StandardError
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user