Skip to content

Use exist? instead of deprecated exists? #3250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

koic
Copy link
Contributor

@koic koic commented Dec 28, 2021

Dir.exists? and `File.exists? were removed by ruby/ruby#5352.
It will be the following error in Ruby 3.2.

% 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.

`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.
@koic
Copy link
Contributor Author

koic commented Dec 28, 2021

The build error is unrelated to this change. #3251 will solve it.

@guillaumebriday guillaumebriday merged commit 550c53e into rails:master Dec 29, 2021
@koic koic deleted the use_exist_instead_of_deprecated_exists branch December 29, 2021 06:10
amatsuda pushed a commit to amatsuda/webpacker that referenced this pull request Jan 20, 2023
`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.
amatsuda pushed a commit to amatsuda/webpacker that referenced this pull request Jan 20, 2023
`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.
byroot added a commit that referenced this pull request Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants