8000 ruby: remove some FPs from `rb/useless-assignment-to-local` by yoff · Pull Request #19164 · github/codeql · GitHub
[go: up one dir, main page]

Skip to content

ruby: remove some FPs from rb/useless-assignment-to-local #19164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ruby: add tests
  • Loading branch information
yoff committed Apr 7, 2025
commit b205fedef47c9402bb9df7cd932609e1195a6f60
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| 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:14:9:14:9 | x | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.rb:8:5:8:5 | x | x |
| DeadStoreOfLocal.rb:21:5:21:5 | x | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLoca 8000 l.rb:21:5:21:5 | x | x |
| TestTemplate.rb:9:1:9:1 | x | This assignment to $@ is useless, since its value is never read. | TestTemplate.rb:9:1:9:1 | x | x |
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
query: queries/variables/DeadStoreOfLocal.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
def test_basic(x)
y = x #$ Alert
y = x + 2
return y
end

def test_retry
x = 0
begin
if x == 0
raise "error"
end
rescue
x = 2 #$ SPURIOUS: Alert
retry
end
return 42
end

def test_binding
x = 4 #$ SPURIOUS: Alert
return binding
end

class Sup
def m(x)
print(x + 1)
end
end

class Sub < Sup
def m(y)
y = 3 # OK - the call to `super` sees the value of y
super
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
require 'erb'

template = ERB.new <<EOF
<%#-*- coding: Big5 -*-%>
\_\_ENCODING\_\_ is <%= \_\_ENCODING\_\_ %>.
x is <%= x %>.
EOF
x = 5 #$ SPURIOUS: Alert
puts template.result
0