-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add recommendations for simple File IO
In his 2016 talk ["Little Snippets"](https://youtu.be/mC9TyVeER_8?t=560) Xavier Noria (@fxn) points out that Ruby 1.8 had the idiom ```ruby File.open(filename, 'w') do |f| f.write(content) end ``` whereas starting with Ruby 1.9 this can be replaced with ```ruby File.write(filename, content) ``` We add this suggestion for simple truncating file writes in text and binary mode, as well as the corresponding scenaro for reading files. The suggestions were also implemented for RuboCop: - `File/Write`: rubocop/rubocop#10260 - `File/Read`: rubocop/rubocop#10261
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters