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

Support AllowComments option for Style/EmptyElse #10790

Merged

Commits on Jul 10, 2022

  1. Support AllowComments option for Style/EmptyElse

    This PR is support `AllowComments` option for `Style/EmptyElse`.
    The default for this option is false.
    
    In the case of complex conditional statements,
    we may want to leave `else` empty or nil and
    write only the explanation of the `else` case in the comments.
    
    `AllowComments: true` will not treat when `else` as offense
    if the `else` with an intentional comment.
    
    ### @example AllowComments: false (default)
    
    ```ruby
    # bad
    if condition
      statement
    else
      # something comment
      nil
    end
    
    # bad
    if condition
      statement
    else
      # something comment
    end
    ```
    
    ### @example AllowComments: true
    
    ```ruby
    # good
    if condition
      statement
    else
      # something comment
      nil
    end
    
    # good
    if condition
      statement
    else
      # something comment
    end
    ```
    ydah committed Jul 10, 2022
    Copy the full SHA
    6f9bc56 View commit details
    Browse the repository at this point in the history