[rust-guard] Group resource identifiers in resolve_author_integrity to drop a too_many_arguments allow
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
- Tipo di issue
- Refactoring
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- backend-api-design
Direzione di ricerca
Leggi guards/github-guard/rust-guard/src/labels/tool_rules.rs, in particolare resolve_author_integrity, i relativi punti di chiamata per issue e PR e il test unitario intorno alle righe indicate. Introduci la struct della risorsa con nome e aggiorna i punti di chiamata e il test affinché la utilizzino. Esegui cargo test e cargo clippy --all-targets del crate; il lavoro è completato quando i test passano e Clippy non segnala nuovi avvisi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Improvement 1: Bundle resource identifiers into AuthoredResource
Category: API Surface / Type Safety
File(s): guards/github-guard/rust-guard/src/labels/tool_rules.rs (lines ~185, ~256, ~436, ~3281)
Effort: Small (< 15 min)
Risk: Low
Problem
resolve_author_integrity takes 9 positional arguments and carries #[allow(clippy::too_many_arguments)]. Four of them (owner, repo, repo_id, and resource_label/resource_num) all describe the same issue or PR. Because they are plain &str positional arguments, the compiler cannot catch a transposed pair such as owner/repo. The two call sites (issue read at ~line 251, PR read at ~line 430) and the unit test at ~line 3269 pass them in the same order, so a swap would be silent.
Suggested Change
Add a small borrowed struct that names the resource, and pass it as one argument. Remove the #[allow]. This drops the function to 5 arguments, below clippy's threshold.
Before
#[allow(clippy::too_many_arguments)]
fn resolve_author_integrity(
owner: &str,
repo: &str,
repo_id: &str,
author_login: Option<&str>,
author_association: Option<&str>,
resource_label: &str,
resource_num: &str,
base_integrity: &[String],
ctx: &PolicyContext,
) -> Vec<String> { /* ... */ }
// call site
integrity = resolve_author_integrity(
owner, repo, repo_id,
info.author_login.as_deref(),
info.author_association.as_deref(),
tool_names::ISSUE_READ, &issue_num,
&integrity, ctx,
);
After
/// Identifies the issue or PR whose author integrity is being resolved.
struct AuthoredResource<'a> {
owner: &'a str,
repo: &'a str,
repo_id: &'a str,
/// Tool name used as the resource kind in debug logs.
label: &'a str,
number: &'a str,
}
fn resolve_author_integrity(
resource: &AuthoredResource<'_>,
author_login: Option<&str>,
author_association: Option<&str>,
base_integrity: &[String],
ctx: &PolicyContext,
) -> Vec<String> {
let repo_id = resource.repo_id;
// ... body unchanged, except resource_id uses resource.owner/repo/number
// and elevate_via_collaborator_permission receives resource.label
}
// call site
integrity = resolve_author_integrity(
&AuthoredResource {
owner, repo, repo_id,
label: tool_names::ISSUE_READ,
number: &issue_num,
},
info.author_login.as_deref(),
info.author_association.as_deref(),
&integrity,
ctx,
);
The full change is attached as proposal.diff (touches only tool_rules.rs, 3 call sites plus the test).
Verification
Run on a scratch copy of the crate, with the repository left untouched:
cargo test: 724 passed, 0 failed before and after the change.cargo clippy --all-targets: warning count unchanged (90needless_borrowand 1field_reassign_with_default, both already tracked in earlier suggestions). No new warnings.rustfmt --check src/labels/tool_rules.rs: clean.- The WASM target (
wasm32-wasip1) is not installed in this environment, so the WASM build was not run. The change is type-level only, with no FFI or ABI surface touched, so no codegen difference is expected.
Why This Matters
- Named fields make the call sites self-describing and remove the risk of silently swapping
owner/repoorlabel/number. - Removes one of the three
too_many_argumentsallows. The remaining two (apply_governance_labelsandapply_issue_read_enrichment, both 8 arguments) are natural follow-ups using the same pattern.
Generated by Rust Guard Improver • Run: 44053257234
Generated by Rust Guard Improver · copilot · routed: haiku55 xhigh · ~5 AIC · ⊞ 5K · ◷
- expires on Nov 24, 2026, 9:17 AM UTC
- Lingua principale
- Go
- Stelle
- 188
- Fork
- 60
- Merge medio
- 6h 50m
- PR unite (30g)
- 177
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di github/gh-aw-mcpg
-
automated documentation maintenance
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
github/gh-aw-mcpg#16717 ·
I maintainer di solito rispondono entro 1 giorno
-
automated-analysis code-quality
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/gh-aw-mcpg#16691 ·
I maintainer di solito rispondono entro 1 giorno
-
go-fan module-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
github/gh-aw-mcpg#16659 ·
I maintainer di solito rispondono entro 1 giorno
-
automated-analysis code-quality refactoring
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
github/gh-aw-mcpg#16716 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
github/gh-aw-mcpg#16714 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di github/gh-aw-mcpg
Issue simili
-
go-vulnerability security-scan
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
teslashibe/agent-go#35 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
alecthomas/chroma#1498 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 8 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno