mirror of
https://github.com/github/codeql.git
synced 2026-05-25 00:27:09 +02:00
Interviewing a Ruby developer, I learned that dealing with nil is common practice. So alerts are mostly useful, if we can point to a place where this has gone wrong.
14 lines
261 B
Ruby
14 lines
261 B
Ruby
def m
|
|
puts "m"
|
|
end
|
|
|
|
def foo
|
|
m # calls m above
|
|
if false
|
|
m = "0"
|
|
m # reads local variable m
|
|
else
|
|
end
|
|
m.strip # reads uninitialized local variable m, `nil`, and crashes
|
|
m2 # undefined local variable or method 'm2' for main (NameError)
|
|
end |