class Rubocop::Cop::Style::WhileUntilModifier

Checks for while and until statements that would fit on one line if written as a modifier while/until.

Constants

MSG

Public Instance Methods

inspect(source_buffer, source, tokens, ast, comments) click to toggle source
# File lib/rubocop/cop/style/favor_modifier.rb, line 104
def inspect(source_buffer, source, tokens, ast, comments)
  return unless ast
  on_node([:while, :until], ast) do |node|
    # discard modifier while/until
    next unless node.loc.end

    if check(node, comments)
      add_offence(:convention, node.loc.expression, MSG)
    end
  end
end