mirror of
https://github.com/github/codeql.git
synced 2026-04-14 03:24:06 +02:00
148 lines
2.1 KiB
Ruby
148 lines
2.1 KiB
Ruby
# Define some variables used below
|
|
a = 0
|
|
b = 0
|
|
c = 0
|
|
d = 0
|
|
e = 0
|
|
f = 0
|
|
|
|
# If expr with no else
|
|
if a > b then
|
|
c
|
|
end
|
|
|
|
# If expr with single else
|
|
if a == b
|
|
c
|
|
else
|
|
d
|
|
end
|
|
|
|
# If expr with multiple nested elsif branches
|
|
if a == 0 then
|
|
c
|
|
elsif a == 1 then
|
|
d
|
|
elsif a == 2 then
|
|
e
|
|
else
|
|
f
|
|
end
|
|
|
|
# If expr with elsif and then no else
|
|
if a == 0
|
|
b
|
|
elsif a == 1
|
|
c
|
|
end
|
|
|
|
# Unless expr with no else
|
|
unless a > b then
|
|
c
|
|
end
|
|
|
|
# Unless expr with else
|
|
unless a == b
|
|
c
|
|
else
|
|
d
|
|
end
|
|
|
|
# If-modified expr
|
|
a = b if c > d
|
|
|
|
# Unless-modified expr
|
|
a = b unless c < d
|
|
|
|
# Ternary if expr
|
|
a = b > c ? d + 1 : e - 2
|
|
|
|
# If expr with empty else (treated as no else)
|
|
if a > b then
|
|
c
|
|
else
|
|
end
|
|
|
|
# If expr with empty then (treated as no then)
|
|
if a > b then
|
|
else
|
|
c
|
|
end
|
|
|
|
# If expr with `&&` on same line as condition and then
|
|
if a && b then
|
|
c
|
|
end
|
|
|
|
# If expr with `&&` at the start of a separate line before then
|
|
if a
|
|
&& b
|
|
then
|
|
c
|
|
end
|
|
|
|
# If expr with `and` at the start of a separate line before then
|
|
# NOTE: This is not parsed correctly, `and b` is parsed as a call
|
|
if a
|
|
and b
|
|
then
|
|
c
|
|
end
|
|
|
|
# If expr with `||` at the start of a separate line before then
|
|
# NOTE: This is not parsed correctly due to the leading `||`
|
|
# if a
|
|
# || b
|
|
# then
|
|
# c
|
|
# end
|
|
|
|
# If expr with `or` at the start of a separate line before then
|
|
# NOTE: This is not parsed correctly, `or b` is parsed as a call
|
|
if a
|
|
or b
|
|
then
|
|
c
|
|
end
|
|
|
|
# If expr with repeated && at the start of a separate line before then
|
|
if a
|
|
&& b
|
|
&& c
|
|
then
|
|
d
|
|
end
|
|
|
|
# If expr with alternating && and || at the start of lines
|
|
# NOTE: This is not parsed correctly due to the leading `||`
|
|
# if a
|
|
# && b
|
|
# || c
|
|
# then
|
|
# d
|
|
# end
|
|
|
|
# If expr with operator at start of line and parentheses
|
|
# NOTE: This is not parsed correctly due to the leading `||`
|
|
# if a
|
|
# && (b
|
|
# || c)
|
|
# then
|
|
# d
|
|
# end
|
|
|
|
# If expr with operator at start of line and parentheses
|
|
# NOTE: This is not parsed correctly due to the leading `||`
|
|
# if a
|
|
# || (b
|
|
# && c)
|
|
# then
|
|
# d
|
|
# end
|
|
|
|
# If expr with && at end of line
|
|
if a &&
|
|
b
|
|
then
|
|
c
|
|
end |