Sha256: d722b3d39569f3f032e6ee31dac6101d08c34ca20e95386d4c18be694463caf3

Contents?: true

Size: 711 Bytes

Versions: 5

Compression:

Stored size: 711 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
            convention(node, :selector)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.15.0 lib/rubocop/cop/style/favor_join.rb
rubocop-0.14.1 lib/rubocop/cop/style/favor_join.rb
rubocop-0.14.0 lib/rubocop/cop/style/favor_join.rb
rubocop-0.13.1 lib/rubocop/cop/style/favor_join.rb
rubocop-0.13.0 lib/rubocop/cop/style/favor_join.rb