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

[Fix #8035] Fix a false positive for Lint/DeprecatedOpenSSLConstant #8040

Commits on May 26, 2020

  1. [Fix rubocop#8035] Fix a false positive for `Lint/DeprecatedOpenSSLCo…

    …nstant`
    
    Fixes rubocop#8035.
    
    This PR fixes a false positive for `Lint/DeprecatedOpenSSLConstant`
    when argument is a variable, method, or constant.
    
    ```console
    % cat example.rb
    MODE = 'cbc'
    OpenSSL::Cipher::AES256.new(MODE)
    
    % bundle exec rubocop --only Lint/DeprecatedOpenSSLConstant -a
    (snip)
    
    Offenses:
    
    example.rb:2:1: W: [Corrected] Lint/DeprecatedOpenSSLConstant: Use
    OpenSSL::Cipher.new('AES-256-MODE') instead of OpenSSL::Cipher::AES256.new(MODE).
    OpenSSL::Cipher::AES256.new(MODE)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    1 file inspected, 1 offense detected, 1 offense corrected
    
    % cat example.rb
    MODE = 'cbc'
    OpenSSL::Cipher.new('AES-256-MODE')
    ```
    
    RuboCop does not have a tracing feature a value of variable, (method,) and constant yet.
    This PR accepts cases where these values are used to prevent auto-correction mistakes.
    
    On the other hand, this change produces false negatives for the deprecated APIs.
    If it is difficult to accept false negatives, I will update this PR to
    warn against these cases and auto-correction will not performed.
    koic committed May 26, 2020
    Configuration menu
    Copy the full SHA
    85dceda View commit details
    Browse the repository at this point in the history