Sha256: 5e8a6a940723e18fac34c58f24a1517d81e10b826b524303d7ebb1ad1327a869

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 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.nil? || 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

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.14.1 lib/rubocop/cop/style/final_newline.rb
rubocop-0.14.0 lib/rubocop/cop/style/final_newline.rb
rubocop-0.13.1 lib/rubocop/cop/style/final_newline.rb