rubocop / rubocop/ruby-style-guide

Discussion: the `private def` idiom.

Open
#618 15 comments 14 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

At my company we have begun using the idiom

private def quux(foo, bar)
  foo <= bar
end

Instead of:

private
def quux(foo, bar)
  foo <= bar
end

This makes private methods more explicit and makes it easier to understand which methods are private, as sometimes the private declaration is somewhere in the middle of a large class.

What do folks think of this idiom? Can we integrate a recommendation in the guide, or at least specify this as an acceptable alternative to the private declaration making all methods below it private?

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 the existing 15-comment discussion to determine whether there is a settled recommendation for the private def idiom. If consensus can be reached, update the relevant Ruby style guide guidance; the work is done when the guide clearly states the preferred or acceptable form.

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
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.