refactor: deduplicate search scope and author integrity in tool_rules.rs#3019
Merged
refactor: deduplicate search scope and author integrity in tool_rules.rs#3019
Conversation
1. Replace search_code's hand-rolled scope resolution (~16 lines) with a call to resolve_search_scope, matching the pattern used by search_issues and search_pull_requests. 2. Extract resolve_author_integrity helper to consolidate the ~45-line author_association + trusted-bot + collaborator-permission elevation blocks duplicated in the issue_read and pull_request_read arms. Net reduction: 50 lines. All existing behavior is preserved. Closes #2986 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors Rust guard labeling logic in tool_rules.rs to reduce duplication and keep scope/integrity handling consistent across tools, without intending to change labeling outcomes.
Changes:
- Updated
search_codeto use the existingresolve_search_scopehelper (matchingsearch_issues/search_pull_requests). - Extracted duplicated issue/PR author-integrity elevation logic into a shared
resolve_author_integrityhelper and reused it at both call sites.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Addresses both improvements from #2986 — deduplicating scope resolution and integrity elevation logic in the Rust guard's
tool_rules.rs.Changes
1.
search_code→ useresolve_search_scope(Improvement 1)search_codebypassed the existingresolve_search_scopehelper and hand-rolled the same repo-extraction logic with 3 mutable variables (~16 extra lines). Replaced with a call toresolve_search_scope, matching the pattern already used bysearch_issuesandsearch_pull_requests.2. Extract
resolve_author_integrityhelper (Improvement 2)The
issue_readandpull_request_readarms each contained ~45 nearly-identical lines for:author_associationExtracted into a single
resolve_author_integrityfunction. Call sites reduced to 5 lines each.Impact
cargo checkCloses #2986