Frame unconditional guard over unreachable code
Author: forthrinCreated Aug 16, 2026Updated Sep 18, 2026
Labelsfeature request
Before submitting
- I have searched the existing issues and this hasn't been requested yet.
Cop name
Lint/UnreachableCode
Is your feature request related to a problem?
Every single line of code following an unconditional branch lights up like a Christmas tree.
"Take the names of everyone here and bring them in for questioning." — Frank Drebin
Describe the solution you'd like
Instead of flagging all the poor, innocent subsequent code lines, flag the kingpin:
Lint/UnconditionalGuard: Code following an always-true guard statement will never run
Code examples
def main
return # if 2 + 2 == 4
_meaning = 42
puts 'Whatever you say'
raise PizzaDough if Date.today.friday?
endDescribe alternatives you've considered
Comment out entire code blocks rather than using return statements to temporarily disengage code blocks. (Have actually resorted to return if 2 + 2 == 4 as a moronic workaround to avoid poking highway patrol.)
Additional context
No response
Source: rubocop/rubocop