class RuboCop::Cop::Layout::LeadingBlankLines
# a comment
# (start of file)
# good
end
class Foo
# (start of file)
# good
# a comment
# (start of file)
# bad
end
class Foo
# (start of file)
# bad
@example
of a file.
This cop checks for unnecessary leading blank lines at the beginning
def autocorrect(node)
def autocorrect(node) range = Parser::Source::Range.new(processed_source.buffer, 0, node.begin_pos) lambda do |corrector| corrector.remove(range) end end
def investigate(processed_source)
def investigate(processed_source) token = processed_source.tokens[0] return unless token && token.line > 1 add_offense(processed_source.tokens[0], location: processed_source.tokens[0].pos) end