Sha256: 5c49d6248f337f962cd58bcd17d7446a8874b3b0ff795831ff3917066ccc7000
Contents?: true
Size: 802 Bytes
Versions: 9
Compression:
Stored size: 802 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 on_while(node) check(node) end def on_until(node) check(node) end private def check(node) return unless node.loc.end return unless fit_within_line_as_modifier_form?(node) add_offense(node, :keyword, message(node.loc.keyword.source)) end def message(keyword) "Favor modifier `#{keyword}` usage when having a single-line body." end end end end end
Version data entries
9 entries across 9 versions & 2 rubygems