Open Earlopain opened 1 month ago
That's an interesting thought. Expanding on it, any if
/case
statement in a void context that returns a literal (in any branch!) should potentially be flagged by this cop.
if cond?
42 # literal returned into void context ⚠️
end
if cond?
42 # literal returned into void context ⚠️
else
foo
end
case val
when 'foo' then 42 # literal returned into void context ⚠️
end
When you write it like that, it looks very similar to #12393
Expected behavior
Offense for the following:
Actual behavior
No offense. There is already handling for
1 if foo?
so this seems like a logical improvement.RuboCop version