Sha256: 491b426c2243f78cb86b1b5694e137d786e4e2f0eb561bed9d09e4d370d8dc5b
Contents?: true
Size: 1007 Bytes
Versions: 3
Compression:
Stored size: 1007 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Style # This cop checks for chaining of a block after another block that spans # multiple lines. # # @example # # Thread.list.find_all do |t| # t.alive? # end.map do |t| # t.object_id # end class MultilineBlockChain < Cop MSG = 'Avoid multi-line chains of blocks.'.freeze def on_block(node) node.send_node.each_node(:send) do |send_node| receiver = send_node.receiver next unless receiver && receiver.block_type? && receiver.multiline? range = range_between(receiver.loc.end.begin_pos, node.send_node.source_range.end_pos) add_offense(nil, range) # Done. If there are more blocks in the chain, they will be # found by subsequent calls to on_block. break end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.50.0 | lib/rubocop/cop/style/multiline_block_chain.rb |
rubocop-0.49.1 | lib/rubocop/cop/style/multiline_block_chain.rb |
rubocop-0.49.0 | lib/rubocop/cop/style/multiline_block_chain.rb |