Sha256: 34719b30a9f6bb196a7126e4171ebe22dceaea810d7c5b2e8f451226dc17a789

Contents?: true

Size: 475 Bytes

Versions: 8

Compression:

Stored size: 475 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    class Encoding < Cop
      ERROR_MESSAGE = 'Missing 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

8 entries across 8 versions & 1 rubygems

Version Path
rubocop-0.5.0 lib/rubocop/cop/encoding.rb
rubocop-0.4.6 lib/rubocop/cop/encoding.rb
rubocop-0.4.5 lib/rubocop/cop/encoding.rb
rubocop-0.4.4 lib/rubocop/cop/encoding.rb
rubocop-0.4.3 lib/rubocop/cop/encoding.rb
rubocop-0.4.2 lib/rubocop/cop/encoding.rb
rubocop-0.4.1 lib/rubocop/cop/encoding.rb
rubocop-0.4.0 lib/rubocop/cop/encoding.rb