Sha256: 93ed860cb1336417e3cbbcfa1ff39c2bab3085aa0c186c6f31096ffc59582b80
Contents?: true
Size: 868 Bytes
Versions: 1
Compression:
Stored size: 868 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Style # 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. class WhileUntilModifier < Cop include StatementModifier 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 next unless fit_within_line_as_modifier_form?(node) add_offense(node, :keyword, message(node.loc.keyword.source)) end end private def message(keyword) "Favor modifier `#{keyword}` usage when having a single-line body." end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.25.0 | lib/rubocop/cop/style/while_until_modifier.rb |