class RuboCop::Cop::Layout::InitialIndentation
end
def foo; end
class A
# good
end
def foo; end
class A
# bad
@example
line in a file.
This cop checks for indentation of the first non-blank non-comment
def autocorrect(range)
def autocorrect(range) ->(corrector) { corrector.remove(range) } end
def first_token
def first_token processed_source.find_token { |t| !t.text.start_with?('#') } end
def investigate(_processed_source)
def investigate(_processed_source) space_before(first_token) do |space| add_offense(space, location: first_token.pos) end end
def space_before(token)
def space_before(token) return unless token return if token.column.zero? space_range = range_with_surrounding_space(range: token.pos, side: :left, newlines: false) # If the file starts with a byte order mark (BOM), the column can be # non-zero, but then we find out here if there's no space to the left # of the first token. return if space_range == token.pos yield range_between(space_range.begin_pos, token.begin_pos) end