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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1 @@
* [#10199](https://github.com/rubocop/rubocop/pull/10199): Change `AllowAdjacentOneLineDefs` config parameter of `Layout/EmptyLineBetweenDefs` to `true` by default . ([@koic][])
8 changes: 4 additions & 4 deletions config/default.yml
Expand Up @@ -511,13 +511,13 @@ Layout/EmptyLineBetweenDefs:
StyleGuide: '#empty-lines-between-methods'
Enabled: true
VersionAdded: '0.49'
VersionChanged: '1.7'
VersionChanged: '<<next>>'
EmptyLineBetweenMethodDefs: true
EmptyLineBetweenClassDefs: true
EmptyLineBetweenModuleDefs: true
# If `true`, this parameter means that single line method definitions don't
# need an empty line between them.
AllowAdjacentOneLineDefs: false
# `AllowAdjacentOneLineDefs` means that single line method definitions don't
# need an empty line between them. `true` by default.
AllowAdjacentOneLineDefs: true
# Can be array to specify minimum and maximum number of empty lines, e.g. [1, 2]
NumberOfEmptyLines: 1

Expand Down
23 changes: 22 additions & 1 deletion lib/rubocop/cop/layout/empty_line_between_defs.rb
Expand Up @@ -77,13 +77,34 @@ module Layout
# def b
# end
#
# @example AllowAdjacentOneLineDefs: true
# @example AllowAdjacentOneLineDefs: true (default)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it'd be nice to put both good and bad examples for the option. I see now with true have only good and with false only bad.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no bad cases because AllowAdjacentOneLineDefs: true only increases allowed good cases.
AllowAdjacentOneLineDefs: true and AllowAdjacentOneLineDefs: false add the same good case.
In any case, I've updated it and AllowAdjacentOneLineDefs: false's example is more clearer :-)

#
# # good
# class ErrorA < BaseError; end
# class ErrorB < BaseError; end
# class ErrorC < BaseError; end
#
# # good
# class ErrorA < BaseError; end
#
# class ErrorB < BaseError; end
#
# class ErrorC < BaseError; end
#
# @example AllowAdjacentOneLineDefs: false
#
# # bad
# class ErrorA < BaseError; end
# class ErrorB < BaseError; end
# class ErrorC < BaseError; end
#
# # good
# class ErrorA < BaseError; end
#
# class ErrorB < BaseError; end
#
# class ErrorC < BaseError; end
#
class EmptyLineBetweenDefs < Base
include RangeHelp
extend AutoCorrector
Expand Down