From d3606ff8a9ab9108b387289bb442e03cd6ca01f9 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Wed, 29 Dec 2021 10:04:05 +0900 Subject: [PATCH] Use `exist?` instead of deprecated `exists?` (#3250) `Dir.exists?` and `File.exists? were removed by https://github.com/ruby/ruby/pull/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 `
': 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. --- .rubocop.yml | 3 +++ lib/install/template.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d0fe8e0d4..3af4b3eb7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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: diff --git a/lib/install/template.rb b/lib/install/template.rb index 6a38f0656..b07377f84 100644 --- a/lib/install/template.rb +++ b/lib/install/template.rb @@ -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" @@ -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" +