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

Enforce consistent indentation for arrays #28

Merged
merged 1 commit into from
Mar 15, 2019
Merged

Conversation

apalmer0
Copy link
Contributor

@apalmer0 apalmer0 commented Feb 14, 2019

# bad
in_a_method_call([
                  :its_like_this
                 ])

# good
in_a_method_call([
  :no_difference
])

documentation

@danfrenette
Copy link
Contributor

I support this, but only from an aesthetic standpoint. I'm not aware of any practical benefits of one option or the other.

@apalmer0
Copy link
Contributor Author

I think this is a purely aesthetic cop, so I don't know that there are any practical benefits to either. Unless you consider readability to be a practical benefit, in which case my opinion is that the "consistent" style is easier to read.

@kevin-j-m
Copy link
Contributor

Does this consider the following valid/in adherence with the style:

array = 
[
  :value
]

and_in_a_method_call(
  [
    :value
  ]
)

@apalmer0
Copy link
Contributor Author

apalmer0 commented Feb 14, 2019

Oh interesting, yeah @kevin-j-m you're right - that syntax satisfies either rule. So I guess the question is how do we feel about option 1 vs option 2? With EnforcedStyle: consistent either will work, with the rubocop default only option 2 works. Seems like we'd rather only have one option than two?

# option 1
method_call([
  :foo,
])

# option 2
method_call(
  [
    :foo,
  ],
)

@kevin-j-m
Copy link
Contributor

So, for me, I'd consider it incredibly unlikely to in-line an array in a method call anyway, so I'm not sure I really care about the method formatting that much, but I would also prefer consistent to special_inside_parentheses were I to see it in a method call.

Is there a scenario where this is actually common that I'm neglecting to consider?

@danfrenette
Copy link
Contributor

Is there a scenario where this is actually common that I'm neglecting to consider?

I can't think of any, for whatever that's worth

Copy link
Contributor

@danfrenette danfrenette left a comment

Choose a reason for hiding this comment

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

It looks like this needs a rebase because we spaced this. The style is solid though 👍

@kevin-j-m kevin-j-m merged commit 8e3d8d9 into master Mar 15, 2019
@kevin-j-m kevin-j-m deleted the indent-array branch March 15, 2019 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants