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 Layout/EmptyLineAroundAttributeAccessor cop #7922

Commits on May 10, 2020

  1. Add new Layout/EmptyLineAroundAttributeAccessor cop

    This PR adds new `Layout/EmptyLineAroundAttributeAccessor` cop
    that checks for a newline after attribute accessor.
    
    ```ruby
    # bad
    attr_accessor :foo
    def do_something
    end
    
    # good
    attr_accessor :foo
    
    def do_something
    end
    
    # good
    attr_accessor :foo
    attr_reader :bar
    attr_writer :baz
    attr :qux
    
    def do_something
    end
    ```
    
    This PR first checks an empty line after an attribute accessor to
    implement the example shown in The Ruby Style Guide's rule.
    rubocop/ruby-style-guide#817
    
    In the future this cop will provide an `EnforcedStyle: around` that
    checks empty lines before and after an attribute accessor, and this
    `EnforcedStyle: only_after` option could be users selectable option.
    koic committed May 10, 2020
    Copy the full SHA
    8831824 View commit details
    Browse the repository at this point in the history