#14702·rubocop

EmptyLineAfterGuardClause should accept commented guard clauses

Author: forthrinCreated Dec 10, 2025Updated Sep 18, 2026
Labelsfeature request

Steps to reproduce the problem

ruby
4.times do |bear|
  next puts 'Papa' if bear == 1
  next puts 'Mama' if bear == 2 
  # next puts 'Little' if bear == 3

  puts 'Goldilocks'
end

Expected behavior

  • Commented guard clauses: No cop
  • Other comments: Cop

Actual behavior

Nothing happens if we comment Papa Bear or Mama Bear, but if we comment out Little Bear, Mama Bear goes EmptyLineAfterGuardClause. This is something of an annoyance, and you have to shuffle the bears to make the Park Ranger happy. However, comments that are not temporarily commented guard clauses should arguably still have their stockings coaled by Santa Claus. (Puns are half the reward of writing these issues...)

RuboCop version

System Version: macOS 26.1 (25B78)
Model Identifier: MacBookAir10,1
ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [arm64-darwin24]
rubocop     2025-12-02 9338710b3