Skip to content

Commit d3606ff

Browse files
koicamatsuda
authored andcommitted
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 061f33b commit d3606ff

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
@@ -109,6 +109,9 @@ Layout/TrailingWhitespace:
109109
Style/RedundantPercentQ:
110110
Enabled: true
111111

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

lib/install/template.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
say "Copying .browserslistrc to app root directory"
1414
copy_file "#{__dir__}/config/.browserslistrc", ".browserslistrc"
1515

16-
if Dir.exists?(Webpacker.config.source_path)
16+
if Dir.exist?(Webpacker.config.source_path)
1717
say "The JavaScript app source directory already exists"
1818
else
1919
say "Creating JavaScript app source directory"
@@ -22,7 +22,7 @@
2222

2323
apply "#{__dir__}/binstubs.rb"
2424

25-
if File.exists?(".gitignore")
25+
if File.exist?(".gitignore")
2626
append_to_file ".gitignore" do
2727
"\n" +
2828
"/public/packs\n" +

0 commit comments

Comments
 (0)