Parent

Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::EndOfLine

This cop checks for Windows-style line endings in the source code.

Constants

MSG

Public Instance Methods

investigate(processed_source) click to toggle source
# File lib/rubocop/cop/style/end_of_line.rb, line 9
def investigate(processed_source)
  buffer = processed_source.buffer
  original_source = IO.read(buffer.name, encoding: 'ascii-8bit')
  change_encoding(original_source)

  original_source.lines.each_with_index do |line, index|
    next unless line =~ /\r$/

    add_offense(nil,
                source_range(buffer,
                             processed_source[0...index],
                             0, line.length),
                MSG)
    # Usually there will be carriage return characters on all or none
    # of the lines in a file, so we report only one offense.
    break
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.