Skip to content

Use public_send instead of send for public methods - #23449

Merged
MikeMcQuaid merged 3 commits into
Homebrew:mainfrom
AbishekRaj2007:use-public-send-over-send
Aug 5, 2026
Merged

Use public_send instead of send for public methods#23449
MikeMcQuaid merged 3 commits into
Homebrew:mainfrom
AbishekRaj2007:use-public-send-over-send

Conversation

@AbishekRaj2007

@AbishekRaj2007 AbishekRaj2007 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

formula.send(:stable)/formula.send(:head), formula.deps.send(type), and SimulateSystem.send(...) were all calling methods that are already public, so there was no real need for send's private-method backdoor.

Switching these to public_send makes that clear to readers and keeps Ruby's normal privacy checks in place if any of these methods are ever made private.

No behaviour change: every target method was confirmed public before switching, and
./bin/brew typecheck/style/tests all pass.

Disclosure : This changes were suggested by Claude Sonnet 5 and fixed by myself, I have edited and reviewed all the changes.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

A few spots were calling send on methods that are already public
(stable, head, deps.build/required/recommended/optional, and
SimulateSystem's os check), so there was no real need for the
private-method backdoor. Switching to public_send makes that clear
and keeps Ruby's privacy checks in place if that ever changes.
Copilot AI lite review requested due to automatic review settings August 5, 2026 15:16
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for your pull request. This has been closed because it appears to be missing the pull request template, perhaps because this was written by an AI not a human. We require humans to read and fill in these templates.

Please edit this pull request to fill in the current pull request template. This workflow will reopen this pull request automatically once the template is complete. Do not open a new pull request for this.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces uses of Ruby鈥檚 send with public_send where the invoked methods are already public, making intent clearer and preserving Ruby鈥檚 method-visibility checks while keeping behaviour unchanged.

Changes:

  • Use Homebrew::SimulateSystem.public_send for dynamically-selected simulating_or_running_on_*? checks.
  • Use formula.public_send for stable/head access in FormulaAuditor.
  • Use formula.deps.public_send(type) in brew info dependency rendering.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
Library/Homebrew/on_system.rb Switches dynamic OS simulation predicate dispatch from send to public_send.
Library/Homebrew/formula_auditor.rb Switches stable/head spec access from send to public_send.
Library/Homebrew/cmd/info.rb Switches dependency bucket dispatch (build/required/etc.) from send to public_send.

馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions Bot reopened this Aug 5, 2026

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@MikeMcQuaid
MikeMcQuaid enabled auto-merge August 5, 2026 15:22
@AbishekRaj2007

Copy link
Copy Markdown
Contributor Author

Thanks!

Thanks! Appreciate the quick review.

@MikeMcQuaid

Copy link
Copy Markdown
Member

@AbishekRaj2007 stop merging in main please

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 5, 2026
@AbishekRaj2007

Copy link
Copy Markdown
Contributor Author

@AbishekRaj2007 stop merging in main please

Ok

Merged via the queue into Homebrew:main with commit c8c7573 Aug 5, 2026
86 of 88 checks passed
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