Sha256: e37bab8ab170dd2b7ee19ae640191a0ecaae437d83b22c9540d35f17af1c2047
Contents?: true
Size: 770 Bytes
Versions: 3
Compression:
Stored size: 770 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # Check for uses of braces or do/end around single line or # multi-line blocks. class Blocks < Cop MULTI_LINE_MSG = 'Avoid using {...} for multi-line blocks.' SINGLE_LINE_MSG = 'Prefer {...} over do...end for single-line blocks.' def on_block(node) block_length = Util.block_length(node) block_begin = node.loc.begin.source if block_length > 0 && block_begin == '{' add_offence(:convention, node.loc.begin, MULTI_LINE_MSG) elsif block_length == 0 && block_begin != '{' add_offence(:convention, node.loc.begin, SINGLE_LINE_MSG) end super end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
rubocop-0.9.1 | lib/rubocop/cop/style/blocks.rb |
sabat-rubocop-0.9.0 | lib/rubocop/cop/style/blocks.rb |
rubocop-0.9.0 | lib/rubocop/cop/style/blocks.rb |