Class: RuboCop::Cop::Style::MultilineWhenThen
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Style::MultilineWhenThen
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/style/multiline_when_then.rb
Overview
Checks uses of the ‘then` keyword in multi-line when statements.
Constant Summary collapse
- MSG =
'Do not use `then` for multiline `when` statement.'
Instance Method Summary collapse
Methods included from AutoCorrector
Instance Method Details
#on_when(node) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/rubocop/cop/style/multiline_when_then.rb', line 37 def on_when(node) return if !node.then? || require_then?(node) range = node.loc.begin add_offense(range) do |corrector| corrector.remove(range_with_surrounding_space(range, side: :left, newlines: false)) end end |