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 Style/RedundantSelfAssignmentBranch cop #9999

Commits on Aug 11, 2021

  1. Add new Style/RedundantSelfAssignmentBranch cop

    This PR adds new `Style/RedundantSelfAssignmentBranch` cop.
    It checks where conditional branch makes redundant self-assignment.
    
    ```ruby
    # bad
    foo = condition ? bar : foo
    
    # good
    foo = bar if condition
    ```
    
    Redundancy for self-assignment to `elsif` may also be detected in future,
    but this PR implements ternary operator-centric detection.
    koic committed Aug 11, 2021
    Copy the full SHA
    178e0a0 View commit details
    Browse the repository at this point in the history