Sha256: bc38971ac2a84d73269554bbb046abd9b920887175e900800e69f37063bb243f
Contents?: true
Size: 784 Bytes
Versions: 84
Compression:
Stored size: 784 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop # Common functionality for cops checking `Enumerable#sort` blocks. module SortBlock extend NodePattern::Macros include RangeHelp def_node_matcher :sort_with_block?, <<~PATTERN (block $(send _ :sort) (args (arg $_a) (arg $_b)) $send) PATTERN def_node_matcher :sort_with_numblock?, <<~PATTERN (numblock $(send _ :sort) $_arg_count $send) PATTERN def_node_matcher :replaceable_body?, <<~PATTERN (send (lvar %1) :<=> (lvar %2)) PATTERN private def sort_range(send, node) range_between(send.loc.selector.begin_pos, node.loc.end.end_pos) end end end end
Version data entries
84 entries across 84 versions & 4 rubygems