Parent

Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::WhileUntilModifier

Checks for while and until statements that would fit on one line if written as a modifier while/until. The maximum line length is configurable.

Public Instance Methods

investigate(processed_source) click to toggle source
# File lib/rubocop/cop/style/while_until_modifier.rb, line 11
def investigate(processed_source)
  return unless processed_source.ast
  on_node([:while, :until], processed_source.ast) do |node|
    # discard modifier while/until
    next unless node.loc.end

    if check(node, processed_source.comments)
      add_offense(node, :keyword,
                  message(node.loc.keyword.source))
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.