Skip to content
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

Make Lint/DeprecatedConstants aware of Net::HTTPServerException #10209

Conversation

koic
Copy link
Member

@koic koic commented Oct 23, 2021

This PR makes Lint/DeprecatedConstants aware of Net::HTTPServerException.

The following warning was introduced since Ruby 2.6.

% ruby -rnet/http -vwe 'p Net::HTTPServerException'
ruby 2.6.8p205 (2021-07-07 revision 67951) [x86_64-darwin19]
-e:1: warning: constant Net::HTTPServerException is deprecated
Net::HTTPServerException

And HTTPClientException (alias) is used as an alternative to HTTPServerException.

The following is the quote from Ruby 2.6.0 release news.

Add Net::HTTPClientException to deprecate Net::HTTPServerException,
whose name is misleading. [Bug #14688]

https://github.com/ruby/ruby/blob/master/doc/NEWS-2.6.0

% ruby -rnet/http -vwe 'p Net::HTTPClientException'
ruby 2.6.8p205 (2021-07-07 revision 67951) [x86_64-darwin19]
Net::HTTPServerException

HTTPClientException does not yet exist in Ruby 2.5, so the following error occurs.

% ruby -rnet/http -vwe 'p Net::HTTPClientException'
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-darwin19]
Traceback (most recent call last):
-e:1:in `<main>': uninitialized constant
Net::HTTPClientException (NameError)
Did you mean?  Net::HTTPServerException

To prevent such errors, the cop's behavior is changed to detect only DeprecatedVersion or higher.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@koic koic changed the title Make Net::HTTPServerException aware of Lint/DeprecatedConstants Make Lint/DeprecatedConstants aware of Net::HTTPServerException Oct 23, 2021
@koic koic force-pushed the make_net_http_server_exception_aware_of_deprecated_constants branch from ca8618c to 31adc66 Compare October 23, 2021 17:38
This PR makes `Lint/DeprecatedConstants` aware of `Net::HTTPServerException`.

The following warning was introduced since Ruby 2.6.

```console
% ruby -rnet/http -vwe 'p Net::HTTPServerException'
ruby 2.6.8p205 (2021-07-07 revision 67951) [x86_64-darwin19]
-e:1: warning: constant Net::HTTPServerException is deprecated
Net::HTTPServerException
```

And `HTTPClientException` (alias) is used as an alternative to `HTTPServerException`.

The following is the quote from Ruby 2.6.0 release news.

> Add `Net::HTTPClientException` to deprecate `Net::HTTPServerException`,
> whose name is misleading. [Bug #14688]

https://github.com/ruby/ruby/blob/master/doc/NEWS-2.6.0

```console
% ruby -rnet/http -vwe 'p Net::HTTPClientException'
ruby 2.6.8p205 (2021-07-07 revision 67951) [x86_64-darwin19]
Net::HTTPServerException
```

`HTTPClientException` does not yet exist in Ruby 2.5, so the following error occurs.

```console
% ruby -rnet/http -vwe 'p Net::HTTPClientException'
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-darwin19]
Traceback (most recent call last):
-e:1:in `<main>': uninitialized constant
Net::HTTPClientException (NameError)
Did you mean?  Net::HTTPServerException
```

To prevent such errors, the cop's behavior is changed to detect only `DeprecatedVersion` or higher.
@koic koic force-pushed the make_net_http_server_exception_aware_of_deprecated_constants branch from 31adc66 to 932375f Compare October 23, 2021 17:41
@bbatsov bbatsov merged commit e1de418 into rubocop:master Oct 24, 2021
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 24, 2021

Looks good. Thanks!

@koic koic deleted the make_net_http_server_exception_aware_of_deprecated_constants branch October 24, 2021 07:08
koic added a commit that referenced this pull request Nov 17, 2022
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.

None yet

2 participants