Sha256: f1cedc994efd0cec6783e41c222c8a8bf137cafb9c07a71de292917effc80f35

Contents?: true

Size: 487 Bytes

Versions: 5

Compression:

Stored size: 487 Bytes

Contents

# encoding: utf-8

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

      def inspect(file, source, tokens, sexp)
        tokens.each_cons(2) do |t1, t2|
          if t1.type == :on_regexp_beg && t1.text =~ /^%r/ &&
              t2.text !~ %r(/.*/)
            add_offence(:convention, t1.pos.lineno, ERROR_MESSAGE)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.7.2 lib/rubocop/cop/percent_r.rb
rubocop-0.7.1 lib/rubocop/cop/percent_r.rb
rubocop-0.7.0 lib/rubocop/cop/percent_r.rb
rubocop-0.6.1 lib/rubocop/cop/percent_r.rb
rubocop-0.6.0 lib/rubocop/cop/percent_r.rb