class RuboCop::Cop::Style::WhenThen
This cop checks for when; uses in case expressions.
@example
# bad case foo when 1; 'baz' when 2; 'bar' end # good case foo when 1 then 'baz' when 2 then 'bar' end
Constants
- MSG
Public Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubocop/cop/style/when_then.rb, line 29 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.begin, ' then') end end
on_when(node)
click to toggle source
# File lib/rubocop/cop/style/when_then.rb, line 23 def on_when(node) return if node.multiline? || node.then? || !node.body add_offense(node, location: :begin) end