Sha256: 22f2cef1fe7b7e755fb5fedb85d3c3fc6800f2d009ea4d1928439326f654c00a

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop enforces the presence of a final newline in each source file.
      class FinalNewline < Cop
        MSG = 'Source files should end with a newline(\n).'

        def investigate(processed_source)
          final_line = processed_source.raw_lines.to_a.last

          unless final_line.end_with?("\n")
            convention(nil,
                       source_range(processed_source.buffer,
                                    processed_source[0...-1],
                                    final_line.length - 1, 1))
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.13.0 lib/rubocop/cop/style/final_newline.rb