Sha256: b6172f31a16720807cd15a56b16e8e668de6d5c8ef6d77d3695aea70107766ad

Contents?: true

Size: 420 Bytes

Versions: 4

Compression:

Stored size: 420 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    class FavorPercentR < Cop
      MSG = 'Use %r for regular expressions matching more ' +
        "than one '/' character."

      def on_regexp(node)
        if node.loc.begin.source == '/' &&
            node.loc.expression.source[1...-1].scan(/\//).size > 1
          add_offence(:convention, node.loc.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_percent_r.rb
rubocop-0.8.2 lib/rubocop/cop/favor_percent_r.rb
rubocop-0.8.1 lib/rubocop/cop/favor_percent_r.rb
rubocop-0.8.0 lib/rubocop/cop/favor_percent_r.rb