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

Add new Lint/NumberedParameterAssignment cop #9326

Merged

Commits on Jan 10, 2021

  1. Add new Lint/NumberedParameterAssignment cop

    This cop checks for uses of numbered parameter assignment.
    It emulates the following warning in Ruby 2.7:
    
    ```console
    % ruby -ve '_1 = :value'
    ruby 2.7.2p137 (2020-10-01 revision 5445e04352)
    [x86_64-darwin19]
    -e:1: warning: `_1' is reserved for numbered parameter; consider another name
    ```
    
    Assiging to numbered parameter (from `_1` to `_9`) cause an error in Ruby 3.0.
    
    ```console
    % ruby -ve '_1 = :value'
    ruby 3.0.0p0 (2020-12-25 revision 95aff21468)
    [x86_64-darwin19]
    -e:1: _1 is reserved for numbered parameter
    ```
    
    NOTE: The parametered parameters are from `_1` to `_9`. This cop checks `_10` and
    above as well to prevent confusion.
    
    ```ruby
    # bad
    _1 = :value
    
    # good
    non_numbered_parameter = :value
    ```
    
    This cop checks numbered (block) parameter other than `_1` to `_9` (e.g.: `_0`, `_10`).
    koic committed Jan 10, 2021
    Configuration menu
    Copy the full SHA
    d47750b View commit details
    Browse the repository at this point in the history