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/EmptyInPattern cop #9825

Merged
merged 1 commit into from May 27, 2021

Commits on May 26, 2021

  1. Add new Lint/EmptyInPattern cop

    This PR adds new `Lint/EmptyInPattern` cop for Ruby 2.7's pattern matching.
    It checks for the presence of `in` branches without a body.
    
    ```ruby
    # bad
    case condition
    in [a]
      do_something
    in [a, b]
    end
    
    # good
    case condition
    in [a]
      do_something
    in [a, b]
      nil
    end
    
    # good - AllowComments: true (default)
    case condition
    in [a]
      do_something
    in [a, b]
      # noop
    end
    
    # bad - AllowComments: false
    case condition
    in [a]
      do_something
    in [a, b]
      # noop
    end
    ```
    
    This cop is similar to `Lint/EmptyWhen`, but with different supported
    syntax and Ruby version (requires 2.7 or higher).
    
    And this PR use rubocop/rubocop-ast#183 feature,
    so it requires RuboCop AST 1.6.0 or higher.
    koic committed May 26, 2021
    Copy the full SHA
    0cc37f6 View commit details
    Browse the repository at this point in the history