-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
New Cop Style/ClosingArrayBraceLayout #2472
New Cop Style/ClosingArrayBraceLayout #2472
Conversation
c47391d
to
94a0237
Compare
76b2446
to
a19a3ae
Compare
Technically speaking this is more of a "multi-line array literal layout". A single brace can't have a layout. :-) |
@bbatsov Maybe the name of the cop should be |
@@ -4,6 +4,12 @@ Style/AutoResourceCleanup: | |||
Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).' | |||
Enabled: false | |||
|
|||
Style/ClosingArrayBraceLayout: | |||
Description: >- | |||
Checks that the closing brace in an array is symmetrical |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in an array literal
I'm fine with both names. |
'from the first array element.' | ||
|
||
def on_array(node) | ||
return unless node.loc.begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally I add comments on guard clauses, so casual readers would know why it's good idea to exit at this point.
ping |
Holiday/vacation. I promise I'll get back to this. On Fri, Dec 25, 2015, 01:20 Bozhidar Batsov [email protected]
|
a19a3ae
to
55048f2
Compare
@bbatsov I've updated with your comments and renamed to |
The build is failing due to a style offense. |
This cop is inspired by a comment in the `Style/LineBreaks` cop PR: rubocop#2277 (comment) This cop checks that the closing brace in an array literal is symmetrical with respect to the opening brace and the array elements. I am very open to suggestions on naming and ways to clarify the offense messages. # bad [ :a, :b ] # bad [ :a, :b ] # good [ :a, :b ] #good [ :a, :b ] My intention is to expand this to account for hashes, method parameters and method arguments once the language and approach is validated.
55048f2
to
8f339af
Compare
@bbatsov fixed |
New Cop Style/MultilineArrayBraceLayout
This cop is inspired by a comment in the
Style/LineBreaks
cop PR:#2277 (comment)
This cop checks that the closing brace in an array is symmetrical with
respect to the opening brace and the array elements. I am very open to
suggestions on naming and ways to clarify the offense messages.
My intention is to expand this to account for hashes, method parameters
and method arguments once the language and approach is validated.