Skip to content

rust-guard: remove dead is_owner, strip stale #[allow(dead_code)] on get_nested_str, extract resolve_search_scope#2434

Merged
lpcox merged 2 commits intomainfrom
copilot/rust-guard-remove-dead-code
Mar 24, 2026
Merged

rust-guard: remove dead is_owner, strip stale #[allow(dead_code)] on get_nested_str, extract resolve_search_scope#2434
lpcox merged 2 commits intomainfrom
copilot/rust-guard-remove-dead-code

Conversation

Copy link
Contributor

Copilot AI commented Mar 24, 2026

Two cleanups in the Rust guard: stale dead-code annotations and duplicated search-scope resolution logic in tool_rules.rs.

helpers.rs

  • Deleted is_owner — zero callers anywhere in the codebase
  • Removed #[allow(dead_code)] from get_nested_str — it's used in production (extract_author_login) and exported; the annotation was incorrect
  • Kept #[allow(dead_code)] on is_bot — only called from #[cfg(test)] code; as a cdylib crate, Rust treats it as dead in production builds and the annotation is still needed for a warning-free build
  • Updated labels/README.md to drop is_owner from the user classification list

tool_rules.rs

Extracted a private resolve_search_scope helper to eliminate the identical 12-line scope-resolution block duplicated across search_issues and search_pull_requests:

fn resolve_search_scope(tool_args: &Value, owner: &str, repo: &str) -> (String, String, String) {
    let query = tool_args.get("query").and_then(|v| v.as_str()).unwrap_or("");
    let (q_owner, q_repo, q_repo_id) = extract_repo_info_from_search_query(query);
    if !q_repo_id.is_empty() {
        (q_owner, q_repo, q_repo_id)
    } else if !owner.is_empty() && !repo.is_empty() {
        (owner.to_string(), repo.to_string(), format_repo_id(owner, repo))
    } else {
        (String::new(), String::new(), String::new())
    }
}

Both match arms now delegate to this helper; only the desc format string differs between them.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /tmp/go-build10436897/b333/launcher.test /tmp/go-build10436897/b333/launcher.test -test.testlogfile=/tmp/go-build10436897/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s -goversion go1.25.8 -c=4 -nolocalimports -importcfg /tmp/go-build10436897/b321/importcfg -pack /tmp/go-build10436897/b321/_testmain.go go_.�� lcache/go/1.25.8/x64=/_/GOROOT rg x_amd64/vet bug/deps/rustcbn/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link bug/deps/github_-o bug/deps/github_/tmp/go-build10436897/b321/rules.test x_amd64/vet (dns block)
  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh issue close 2430 --comment Resolved in this PR: removed dead is_ownerfunction, stripped the stale#[allow(dead_code)]fromget_nested_str(which is used in production), and extracted aresolve_search_scope helper to eliminate the duplicated search-scope resolution logic in ore-10e2da29e93378c1/build_script_build-10e2da29e93378c1 lib/rustlib/x86_64-REDACTED-linux-gnu/bin/rust-lld ug/build/serde-3rustc -I 64/pkg/tool/linu--edition=2021 lib/rustlib/x86_--crate-name=proc_macro2 lib/�� lib/rustlib/x86_--cap-lints=allow lib/rustlib/x86_--emit=dep-info,metadata lib/rustlib/x86_--out-dir lib/rustlib/x86_git lib/rustlib/x86_checkout lib/rustlib/x86_copilot/rust-guard-remove-dead-code lib/rustlib/x86_x86_64-REDACTED-linux-gnu (http block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build10436897/b318/config.test /tmp/go-build10436897/b318/config.test -test.testlogfile=/tmp/go-build10436897/b318/testlog.txt -test.paniconexit0 -test.timeout=10m0s ortc�� g_.a 64/src/crypto/ecdh/ecdh.go u/13/cc1 guard-d6a03f414d/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet nal guard-d6a03f414d-unreachable=false u/13/cc1 guar�� UuTnnb-7k guard-d6a03f414dc506a0.2cvaxrr0e-nolocalimports x_amd64/vet guard-d6a03f414d/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet guard-d6a03f414d-unsafeptr=false bug/build/serde--unreachable=false x_amd64/vet (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build10436897/b333/launcher.test /tmp/go-build10436897/b333/launcher.test -test.testlogfile=/tmp/go-build10436897/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s -goversion go1.25.8 -c=4 -nolocalimports -importcfg /tmp/go-build10436897/b321/importcfg -pack /tmp/go-build10436897/b321/_testmain.go go_.�� lcache/go/1.25.8/x64=/_/GOROOT rg x_amd64/vet bug/deps/rustcbn/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link bug/deps/github_-o bug/deps/github_/tmp/go-build10436897/b321/rules.test x_amd64/vet (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build10436897/b333/launcher.test /tmp/go-build10436897/b333/launcher.test -test.testlogfile=/tmp/go-build10436897/b333/testlog.txt -test.paniconexit0 -test.timeout=10m0s -goversion go1.25.8 -c=4 -nolocalimports -importcfg /tmp/go-build10436897/b321/importcfg -pack /tmp/go-build10436897/b321/_testmain.go go_.�� lcache/go/1.25.8/x64=/_/GOROOT rg x_amd64/vet bug/deps/rustcbn/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link bug/deps/github_-o bug/deps/github_/tmp/go-build10436897/b321/rules.test x_amd64/vet (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build10436897/b342/mcp.test /tmp/go-build10436897/b342/mcp.test -test.testlogfile=/tmp/go-build10436897/b342/testlog.txt -test.paniconexit0 -test.timeout=10m0s go_.�� 64/src/net -trimpath x_amd64/vet -p ions =0 x_amd64/vet swit�� /tmp/go-build396go1.25.8 0626853/b151/ x_amd64/vet -p crypto/internal//usr/bin/runc -lang=go1.25 x_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

…tr, extract resolve_search_scope

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/27593cdd-ca89-4263-8b3b-ab102d27c749
Copilot AI changed the title [WIP] Remove dead is_owner and obsolete #[allow(dead_code)] annotations rust-guard: remove dead is_owner, strip stale #[allow(dead_code)] on get_nested_str, extract resolve_search_scope Mar 24, 2026
Copilot AI requested a review from lpcox March 24, 2026 13:47
@lpcox lpcox marked this pull request as ready for review March 24, 2026 18:16
Copilot AI review requested due to automatic review settings March 24, 2026 18:16
@lpcox lpcox merged commit 92130f3 into main Mar 24, 2026
15 checks passed
@lpcox lpcox deleted the copilot/rust-guard-remove-dead-code branch March 24, 2026 18:16
Copy link
Contributor

Copilot AI left a comment

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 performs small maintainability cleanups in the Rust guard labeling logic by removing truly unused code/annotations and de-duplicating search-scope resolution in apply_tool_labels.

Changes:

  • Added a private resolve_search_scope() helper in tool_rules.rs and used it for both search_issues and search_pull_requests.
  • Removed a stale #[allow(dead_code)] from get_nested_str (it’s used in non-test code) and deleted the unused is_owner helper.
  • Updated labels/README.md to remove is_owner from the documented helper list.

Reviewed changes

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

File Description
guards/github-guard/rust-guard/src/labels/tool_rules.rs Extracts and reuses search repo-scope resolution logic for consistent labeling behavior.
guards/github-guard/rust-guard/src/labels/helpers.rs Removes unused is_owner and corrects dead-code annotations based on actual usage.
guards/github-guard/rust-guard/src/labels/README.md Updates module documentation to match the helper set after cleanup.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants