Ruby: Inline expectation should have space before $

This commit is contained in:
Owen Mansel-Chan
2026-03-04 12:39:10 +00:00
parent 91b6801db1
commit 1950fd33db
4 changed files with 72 additions and 72 deletions

View File

@@ -1,5 +1,5 @@
def test_basic(x)
y = x #$ Alert
y = x # $ Alert
y = x + 2
return y
end
@@ -27,7 +27,7 @@ class Sup
print(x + 1)
end
end
class Sub < Sup
def m(y)
y = 3 # OK - the call to `super` sees the value of `y``
@@ -39,7 +39,7 @@ def do_twice
yield
yield
end
def get_done_twice x
do_twice do
print x
@@ -52,7 +52,7 @@ def retry_once
rescue
yield
end
def get_retried x
retry_once do
print x
@@ -63,4 +63,4 @@ def get_retried x
end
end
end
end
end

View File

@@ -9,7 +9,7 @@ def foo
m # reads local variable m
else
end
m.strip #$ Alert
m.strip # $ Alert
m2 # undefined local variable or method 'm2' for main (NameError)
end
@@ -31,7 +31,7 @@ def test_guards
b&.strip # OK - safe navigation
b.strip if b # OK
b.close if b && !b.closed # OK
b.blowup if b || !b.blownup #$ Alert
b.blowup if b || !b.blownup # $ Alert
if false
c = "0"
@@ -64,7 +64,7 @@ def test_loop
a = 0
else
set_a
end
end
end until a # OK
a.strip # OK - given previous until
end
@@ -73,5 +73,5 @@ def test_for
for i in ["foo", "bar"] # OK - since 0..10 cannot raise
puts i.strip
end
i.strip #$ SPURIOUS: Alert
end
i.strip # $ SPURIOUS: Alert
end