Sha256: d50e9fa3f3b7485427710519f4d8317f1e87784cfcbe8af1f9ca70e46635d8f2

Contents?: true

Size: 421 Bytes

Versions: 4

Compression:

Stored size: 421 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    class PercentR < Cop
      MSG = 'Use %r only 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/percent_r.rb
rubocop-0.8.2 lib/rubocop/cop/percent_r.rb
rubocop-0.8.1 lib/rubocop/cop/percent_r.rb
rubocop-0.8.0 lib/rubocop/cop/percent_r.rb