Sha256: cf051ef9da10bf279dcb9461549ff6d0446d787182133ae4dced31b17efafbc9
Contents?: true
Size: 903 Bytes
Versions: 2
Compression:
Stored size: 903 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 if check(node, processed_source.comments) add_offense(node, :keyword, message(node.loc.keyword.source)) end end end private def message(keyword) "Favor modifier #{keyword} usage when you have a single-line body." end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | lib/rubocop/cop/style/while_until_modifier.rb |
rubocop-0.19.0 | lib/rubocop/cop/style/while_until_modifier.rb |