class RuboCop::Cop::Layout::Tab


end
bar
def foo
# This example uses spaces to indent bar.
# good
end
bar
def foo
# This example uses a tab to indent bar.
# bad
@example
This cop checks for tabs inside the source code.

def autocorrect(range)

def autocorrect(range)
  lambda do |corrector|
    spaces = ' ' * configured_indentation_width
    corrector.replace(range, range.source.gsub(/\t/, spaces))
  end
end

def in_string_literal?(ranges, line, col)

rubocop:disable Metrics/CyclomaticComplexity
def in_string_literal?(ranges, line, col)
  ranges.any? do |range|
    (range.line == line && range.column <= col) ||
      (range.line < line && line < range.last_line) ||
      (range.line != line && range.last_line == line &&
       range.last_column >= col)
  end
end

def investigate(processed_source)

def investigate(processed_source)
  str_ranges = string_literal_ranges(processed_source.ast)
  processed_source.lines.each.with_index(1) do |line, lineno|
    match = line.match(/^([^\t]*)\t+/)
    next unless match
    prefix = match.captures[0]
    col = prefix.length
    next if in_string_literal?(str_ranges, lineno, col)
    range = source_range(processed_source.buffer,
                         lineno,
                         col...match.end(0))
    add_offense(range, location: range)
  end
end

def string_literal_ranges(ast)

def string_literal_ranges(ast)
  # which lines start inside a string literal?
  return [] if ast.nil?
  ast.each_node(:str, :dstr).each_with_object(Set.new) do |str, ranges|
    loc = str.location
    range = if str.heredoc?
              loc.heredoc_body
            else
              loc.expression
            end
    ranges << range
  end
end