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 #11399] Add new Style/UnlessMinimizeNegations cop #11662

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Mar 4, 2023

  1. [Fix rubocop#11399] Add new Style/UnlessMinimizeNegations cop

    Fixes rubocop#11399.
    This PR adds new `Style/UnlessMinimizeNegations` cop.
    
    It minimizes the number of negations in an `unless` using De Morgan’s laws.
    
    ```ruby
    # bad (all terms negated)
    do_something unless !x && !y
    
    # good (all terms positive)
    do_something if x || y
    
    # bad (2 negations, 1 positive)
    do_something unless !x || !y || z
    
    # good (2 positives, 1 negation)
    do_something if x && y && !z
    ```
    SparLaimor committed Mar 4, 2023
    Configuration menu
    Copy the full SHA
    16b86fc View commit details
    Browse the repository at this point in the history