Skip to content

Files

Latest commit

 

History

History
28 lines (20 loc) · 595 Bytes

Style-FileEmpty.md

File metadata and controls

28 lines (20 loc) · 595 Bytes

Pattern: Missing use of File.empty?('path/to/file')

Issue: -

Description

Prefer to use File.empty?('path/to/file') when checking if a file is empty.

Examples

# bad
File.zero?('path/to/file')
File.size('path/to/file') == 0
File.size('path/to/file') >= 0
File.size('path/to/file').zero?
File.read('path/to/file').empty?
File.binread('path/to/file') == ''
FileTest.zero?('path/to/file')

# good
File.empty?('path/to/file')
FileTest.empty?('path/to/file')

Further Reading