Skip to content

Files

Latest commit

 

History

History
32 lines (24 loc) · 535 Bytes

Style-FileRead.md

File metadata and controls

32 lines (24 loc) · 535 Bytes

Pattern: Missing use of File.(bin)read

Issue: -

Description

Favor File.(bin)read convenience methods.

Examples

## text mode
# bad
File.open(filename).read
File.open(filename, &:read)
File.open(filename) { |f| f.read }
File.open(filename) do |f|
  f.read
end
File.open(filename, 'r').read
File.open(filename, 'r', &:read)
File.open(filename, 'r') do |f|
  f.read
end

# good
File.read(filename)

Further Reading