Use .public_send instead of .send for calls to public methods - #23458
Open
AbishekRaj2007 wants to merge 1 commit into
Open
Use .public_send instead of .send for calls to public methods#23458AbishekRaj2007 wants to merge 1 commit into
AbishekRaj2007 wants to merge 1 commit into
Conversation
MikeMcQuaid
reviewed
Aug 7, 2026
MikeMcQuaid
left a comment
Member
There was a problem hiding this comment.
Looks good so far! Please force-push to trigger CI again after the GitHub incident.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While going through the codebase for calls that use .send to invoke a method by a dynamic name, I found a batch of spots where the method being called is actually public .send was being used just to look up a method whose name isn't known until runtime (e.g. Tty.send(color), formula.send(spec_name)), not because anything private needed to be reached.
Since .send bypasses Ruby's private visibility check entirely, using it on public methods is a bit misleading to read — it makes a caller look like it might be reaching into internals when it isn't. public_send does the exact same dynamic lookup but only succeeds if the method is actually public, so it documents that intent and behaves identically here since every method involved already was public.
For each of the 20 call sites, I checked the receiver's class definition to confirm the method has no private marker before switching it over, so this should be a no-op behavior-wise.
Left untouched (need private access, so can't switch):
Note: I have used Claude Sonnet 5 only to change in code and carefully reviewed it before pushing and this PR was raised by myself and no AI is involved in writing the pr.
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?