rubocop / rubocop/ruby-style-guide

Style for Arrays of Hashes and similar constructs

Open
#302 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
16.5k
Forks
3.3k
PR merge metrics
No merged PRs in 30d

Description

I came to check the guide for suggestions but didn't see anything for this.

# clear but can we make it more compact?
people = [
  {
    :name => "John Smith",
    :address => "123 Street St, City, Region, Country"
  },
  {
    :name => "Jane Smith",
    :address => "321 Avenue Ave, City, Region, Country"
  }
]

# compact but less readable if we start wrapping, likely if we add additional keys
people = [
  { :name => "John Smith", :address => "123 Street St, City, Region, Country" },
  { :name => "Jane Smith", :address => "321 Avenue Ave, City, Region, Country" }
]

# fairly clear but the braces don't line up and we only saved 2 rows
people = [{
    :name => "John Smith",
    :address => "123 Street St, City, Region, Country"
  },
  {
    :name => "Jane Smith",
    :address => "321 Avenue Ave, City, Region, Country"
}]

I'm not totally happy with any of these. Any other suggestions?

Thanks for all the hard work on this guide, BTW!

-Michael

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file or test is identified in the issue. Review the existing Ruby style guide and this issue's discussion for related guidance; done means the community agrees on a recommendation and the guide documents it.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.