class SimpleCov::SourceFile

def ensure_remove_undefs(file_lines)

def ensure_remove_undefs(file_lines)
  # invalid/undef replace are technically not really necessary but nice to
  # have and work around a JRuby incompatibility. Also moved here from
  # simplecov-html to have encoding shenaningans in one place. See #866
  # also setting these option on `file.set_encoding` doesn't seem to work
  # properly so it has to be done here.
  file_lines.each do |line|
    if line.encoding == Encoding::UTF_8
      line
    else
      line.encode!("UTF-8", invalid: :replace, undef: :replace)
    end
  end
end