rubocop / rubocop/ruby-style-guide

Numbered parameters

Open
#885 2 comments 1 reaction 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

Following my PR introducing a cop for numbered parameters, @koic suggested that choosing the default style required a discussion in the style guide.

As a basis, here is what we agreed upon in our team. "Explicit" array name is not per se enforcable with a cop, so I'm not sure how it would fit in the guide.

# bad - non explicit array name
results = electric_appliance.process!
results.each { _1.taste }

# bad - multi line block
waffles.each do 
  topping = @user.toppings.max_by(&:evaluation)
  _1.spread topping
end

# bad - block can be created from method
waffles.each { _1.taste } # => waffles.each(&:taste)
waffles.each { taste(_1) } # => waffles.each(&method(:taste))

# good - explicit array name + single line block + necessity to write block
waffles.each { _1.spread(jam) }
waffles.filter { _1.baking == :well_done }

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

Start by reviewing this issue together with the linked PR introducing the numbered-parameters cop and its referenced discussion. Compare the proposed bad and good examples, resolve the open question about explicit array names and default style, and update the style guide once the project’s position is agreed.

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.