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

Comma added at the end of a multiline hash in fonction call #26

Closed
martinos opened this issue Oct 3, 2017 · 4 comments
Closed

Comma added at the end of a multiline hash in fonction call #26

martinos opened this issue Oct 3, 2017 · 4 comments

Comments

@martinos
Copy link

martinos commented Oct 3, 2017

I noticed that if a pass a hash to a function and I put every key-value pair on its own line, the last key-value pair gets a comma appended to it.

    create(
      name: "Joe",
      email: "bob@example.net",
      customer_id: cust.id,
    )

In this case a comma is added after the customer_id value.

I think this is not the expected behaviour.

@splattael
Copy link
Member

Hi @martinos,

thanks for reporting. Can you share your rufo settings (in ~/.rufo)?

A comma only gets appended if trailing_commas is set to :always.

Kind regards,
Peter

@martinos
Copy link
Author

martinos commented Oct 4, 2017

Sure, I should have already done that.

Here it is:

indent_size                 2
spaces_inside_hash_brace    :always
spaces_inside_array_bracket :never
spaces_around_equal         :one
spaces_in_ternary           :one
spaces_in_suffix            :one
spaces_in_commands          :dynamic
spaces_around_block_brace   :one
spaces_after_comma          :dynamic
spaces_around_hash_arrow    :one
spaces_around_when          :one
spaces_around_dot           :no
spaces_after_lambda_arrow   :no
spaces_around_unary         :no
spaces_around_binary        :one
parens_in_def               :yes
double_newline_inside_type  :no
visibility_indent           :align
trailing_commas             :always
align_comments              true
align_assignments           false
align_hash_keys             false
align_case_when             true
align_chained_calls         true

My rufo version:

$ rufo -v
rufo 0.1.0

I get it, I don't know why it was set to :always. Thanks for response. Personally, I don't see the point of having this option, there is probably a good reason. I have never seen a trailing comma in a array or a hash in Ruby code. I imagine that it makes it easier to move elements around.

@martinos
Copy link
Author

martinos commented Oct 4, 2017

It's the first time that I look at the spec, I got my answer there.

@splattael
Copy link
Member

@martinos 👍

There is already a discussion to have only "One True Format". #2 (comment)

Feel free to join the fun 😎

@bessey bessey closed this as completed Oct 8, 2017
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

No branches or pull requests

3 participants