Ir al contenido

Stream Not Closed (ARCH6081)

Esta página aún no está disponible en tu idioma.

Key ruby.performance.stream-not-closed · Severity warning · Category performance

A stream or reader opened without a scoped close block leaks file descriptors. Open the stream with the block form.

def read_lines(path)
io = File.open(path)
io.readlines
end
def read_lines(path)
File.open(path) do |io|
io.readlines
end
end

Open streams and IO handles with the block form so they close automatically when the block ends.