class RuboCop::Cop::Layout::LeadingEmptyLines

Checks for unnecessary leading blank lines at the beginning of a file.

@example

# bad
# (start of file)

class Foo
end

# bad
# (start of file)

# a comment

# good
# (start of file)
class Foo
end

# good
# (start of file)
# a comment

Constants

MSG

Public Instance Methods

on_new_investigation() click to toggle source
# File lib/rubocop/cop/layout/leading_empty_lines.rb, line 35
def on_new_investigation
  token = processed_source.tokens[0]
  return unless token && token.line > 1

  add_offense(token.pos) do |corrector|
    range = Parser::Source::Range.new(processed_source.buffer, 0, token.begin_pos)

    corrector.remove(range)
  end
end