Sha256: f7c277fbfc0ff7b9649eb2894f9c99a0fd7c09ce0781c9697fbe47f6110c58dd

Contents?: true

Size: 483 Bytes

Versions: 4

Compression:

Stored size: 483 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    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_offence(:convention,
                      node.loc.expression.line,
                      MSG)
        end

        super
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.8.3 lib/rubocop/cop/favor_join.rb
rubocop-0.8.2 lib/rubocop/cop/favor_join.rb
rubocop-0.8.1 lib/rubocop/cop/favor_join.rb
rubocop-0.8.0 lib/rubocop/cop/favor_join.rb