Sha256: 57b8d32a4abf13f0f5eb1c8d2a3e8cd7650bc5bbcb6859d49edadf183c9fbbd9

Contents?: true

Size: 807 Bytes

Versions: 4

Compression:

Stored size: 807 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # This cop looks for trailing blank lines in the source code.
      class TrailingBlankLines < Cop
        MSG = '%d trailing blank lines detected.'

        def investigate(processed_source)
          blank_lines = 0

          processed_source.lines.reverse_each do |line|
            if line.blank?
              blank_lines += 1
            else
              break
            end
          end

          if blank_lines > 0
            convention(nil,
                       source_range(processed_source.buffer,
                                    processed_source[0...-blank_lines],
                                    0, 1),
                       format(MSG, blank_lines))
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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