Sha256: 717c6e52de3a2c24fa76999514699d088940c17ce1ee12e399462549fbc9ddc3

Contents?: true

Size: 481 Bytes

Versions: 5

Compression:

Stored size: 481 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    class Encoding < Cop
      ERROR_MESSAGE = 'Missing utf-8 encoding comment.'

      def inspect(file, source, tokens, sexp)
        unless RUBY_VERSION >= '2.0.0'
          expected_line = 0
          expected_line += 1 if source[expected_line] =~ /^#!/
          unless source[expected_line] =~ /#.*coding: (UTF|utf)-8/
            add_offence(:convention, 1, 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/encoding.rb
rubocop-0.7.1 lib/rubocop/cop/encoding.rb
rubocop-0.7.0 lib/rubocop/cop/encoding.rb
rubocop-0.6.1 lib/rubocop/cop/encoding.rb
rubocop-0.6.0 lib/rubocop/cop/encoding.rb