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

Change AllowAdjacentOneLineDefs config parameter of Layout/EmptyLineBetweenDefs to true by default #10199

Commits on Oct 25, 2021

  1. Change AllowAdjacentOneLineDefs config parameter of `Layout/EmptyLi…

    …neBetweenDefs` to `true` by default
    
    This PR changes `AllowAdjacentOneLineDefs` config parameter of `Layout/EmptyLineBetweenDefs` to `true` by default.
    
    Currently, warnings that occur are different for each type of definition grouped as shown below.
    
    ```console
    % cat example.rb
    class FooError < StandardError; end
    class BarError < StandardError; end
    class BazError < StandardError; end
    
    attr_accessor :foo
    attr_accessor :bar
    attr_accessor :baz
    
    before_action :do_foo
    before_action :do_bar
    before_action :do_baz
    ```
    
    ```console
    % bundle exec rubocop
    (snip)
    
    Inspecting 1 file
    C
    
    Offenses:
    
    example.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment:
    Missing frozen string literal comment.
    class FooError < StandardError; end
    ^
    example.rb:2:1: C: [Correctable] Layout/EmptyLineBetweenDefs: Expected 1
    empty line between class definitions; found 0.
    class BarError < StandardError; end
    ^^^^^^^^^^^^^^
    example.rb:3:1: C: [Correctable] Layout/EmptyLineBetweenDefs: Expected 1
    empty line between class definitions; found 0.
    class BazError < StandardError; end
    ^^^^^^^^^^^^^^
    
    1 file inspected, 3 offenses detected, 3 offenses auto-correctable
    ```
    
    This `AllowAdjacentOneLineDefs: true` makes it consistent so that there are no blank lines when
    grouped by one liner definitions.
    koic committed Oct 25, 2021
    Copy the full SHA
    d0e9aa1 View commit details
    Browse the repository at this point in the history