Skip to content

Commit 550c53e

Browse files
authored
Use exist? instead of deprecated exists? (#3250)
`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.
1 parent 90f0db7 commit 550c53e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ Layout/TrailingWhitespace:
110110
Style/RedundantPercentQ:
111111
Enabled: true
112112

113+
Lint/DeprecatedClassMethods:
114+
Enabled: true
115+
113116
# Align `end` with the matching keyword or starting expression except for
114117
# assignments, where it should be aligned with the LHS.
115118
Layout/EndAlignment:

lib/install/template.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
say "Copying webpack core config"
66
directory "#{__dir__}/config/webpack", "config/webpack"
77

8-
if Dir.exists?(Webpacker.config.source_path)
8+
if Dir.exist?(Webpacker.config.source_path)
99
say "The packs app source directory already exists"
1010
else
1111
say "Creating packs app source directory"
@@ -16,7 +16,7 @@
1616
apply "#{__dir__}/binstubs.rb"
1717

1818
git_ignore_path = Rails.root.join(".gitignore")
19-
if File.exists?(git_ignore_path)
19+
if File.exist?(git_ignore_path)
2020
append_to_file git_ignore_path do
2121
"\n" +
2222
"/public/packs\n" +

0 commit comments

Comments
 (0)