Skip to content

Commit

Permalink
Use exist? instead of deprecated exists? (#3250)
Browse files Browse the repository at this point in the history
`Dir.exists?` and `File.exists? were removed by ruby/ruby#5352.
It will be the following error in Ruby 3.2.

```console
% ruby -ve 'File.exists?("foo.rb")'
ruby 3.2.0dev (2021-12-28T15:22:18Z master 39b3aa4fb3) [x86_64-darwin19]
-e:1:in `<main>': undefined method `exists?' for File:Class (NoMethodError)

File.exists?("foo.rb")
    ^^^^^^^^
Did you mean?  exist?
```

And this PR enables `Lint/DeprecatedClassMethods` cop to detect these deprecated methods.
  • Loading branch information
koic authored and amatsuda committed Jan 20, 2023
1 parent 061f33b commit d3606ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ Layout/TrailingWhitespace:
Style/RedundantPercentQ:
Enabled: true

Lint/DeprecatedClassMethods:
Enabled: true

# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Layout/EndAlignment:
Expand Down
4 changes: 2 additions & 2 deletions lib/install/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
say "Copying .browserslistrc to app root directory"
copy_file "#{__dir__}/config/.browserslistrc", ".browserslistrc"

if Dir.exists?(Webpacker.config.source_path)
if Dir.exist?(Webpacker.config.source_path)
say "The JavaScript app source directory already exists"
else
say "Creating JavaScript app source directory"
Expand All @@ -22,7 +22,7 @@

apply "#{__dir__}/binstubs.rb"

if File.exists?(".gitignore")
if File.exist?(".gitignore")
append_to_file ".gitignore" do
"\n" +
"/public/packs\n" +
Expand Down

0 comments on commit d3606ff

Please sign in to comment.