class RuboCop::Cop::Style::WhileUntilModifier
end
x += 100
while x < 500 # a long comment that makes code too long if it were a single line
# good
x += 100 while x < 500 # a long comment that makes code too long if it were a single line
# bad
@example
x += 1 until x > 10
# good
end
x += 1
until x > 10
# bad
@example
x += 1 while x < 10
# good
end
x += 1
while x < 10
# bad
@example
configured in the ‘Layout/LineLength` cop.
if written as a modifier while/until. The maximum line length is
Checks for while and until statements that would fit on one line
def on_while(node)
def on_while(node) return unless single_line_as_modifier?(node) add_offense(node.loc.keyword, message: format(MSG, keyword: node.keyword)) do |corrector| corrector.replace(node, to_modifier_form(node)) end end