Sha256: b1d182a96d0639205af7c2b78dc69cdf06c5f606951fb97fcaa9100c51a421ac
Contents?: true
Size: 712 Bytes
Versions: 2
Compression:
Stored size: 712 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # This cop checks for uses of "*" as a substitute for *join*. # # Not all cases can reliably checked, due to Ruby's dynamic # types, so we consider only cases when the first argument is an # array literal or the second is a string literal. class FavorJoin < Cop MSG = 'Favor Array#join over Array#*.' def on_send(node) receiver_node, method_name, *arg_nodes = *node if receiver_node && receiver_node.type == :array && method_name == :* && arg_nodes[0].type == :str add_offense(node, :selector) end 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/favor_join.rb |
rubocop-0.19.0 | lib/rubocop/cop/style/favor_join.rb |