class RuboCop::Cop::Style::MultilineIfThen
end
elsif cond then b
if cond then a
# If statements can contain ‘then` on the same line.
# good
end
if cond then
# This is considered bad practice.
# bad
@example
Checks for uses of the `then` keyword in multi-line if statements.
def autocorrect(node)
def autocorrect(node) lambda do |corrector| corrector.remove( range_with_surrounding_space(range: node.loc.begin, side: :left) ) end end
def non_modifier_then?(node)
def non_modifier_then?(node) node.loc.begin && node.loc.begin.source_line =~ NON_MODIFIER_THEN end
def on_normal_if_unless(node)
def on_normal_if_unless(node) return unless non_modifier_then?(node) add_offense(node, location: :begin, message: format(MSG, keyword: node.keyword)) end