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.
Incorrect
Section titled “Incorrect”def read_lines(path) io = File.open(path) io.readlinesendCorrect
Section titled “Correct”def read_lines(path) File.open(path) do |io| io.readlines endendOpen streams and IO handles with the block form so they close automatically when the block ends.