Use public_send instead of send for public methods - #23449
Conversation
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.
|
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. |
There was a problem hiding this comment.
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_sendfor dynamically-selectedsimulating_or_running_on_*?checks. - Use
formula.public_sendforstable/headaccess inFormulaAuditor. - Use
formula.deps.public_send(type)inbrew infodependency 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.
Thanks! Appreciate the quick review. |
|
@AbishekRaj2007 stop merging in main please |
Ok |
formula.send(:stable)/formula.send(:head),formula.deps.send(type), andSimulateSystem.send(...)were all calling methods that are already public, so there was no real need forsend's private-method backdoor.Switching these to
public_sendmakes 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/testsall pass.Disclosure : This changes were suggested by Claude Sonnet 5 and fixed by myself, I have edited and reviewed all the changes.
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?