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

Commits on Oct 23, 2021

  1. Make Lint/DeprecatedConstants aware of Net::HTTPServerException

    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 committed Oct 23, 2021
    Copy the full SHA
    932375f View commit details
    Browse the repository at this point in the history