[rust-guard] Group resource identifiers in resolve_author_integrity to drop a too_many_arguments allow
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 65/100
- issue の種類
- リファクタリング
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
guards/github-guard/rust-guard/src/labels/tool_rules.rsを読み、特にresolve_author_integrity、issueとPRからの呼び出し箇所、および指定された行付近の単体テストを確認してください。名前付きリソース構造体を導入し、呼び出し箇所とテストを更新してそれを使うようにしてください。crateのcargo testとcargo clippy --all-targetsを実行してください。テストが成功し、Clippyが新たな警告を報告しなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Go
- スター
- 188
- フォーク
- 60
- 平均マージ
- 6時間 50分
- マージ済み PR(30日)
- 177
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/gh-aw-mcpg のほかの issue
-
automated documentation maintenance
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
github/gh-aw-mcpg#16717 ·
メンテナーはふだん 1 日以内に返信
-
automated-analysis code-quality
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
github/gh-aw-mcpg#16691 ·
メンテナーはふだん 1 日以内に返信
-
go-fan module-review
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
github/gh-aw-mcpg#16659 ·
メンテナーはふだん 1 日以内に返信
-
automated-analysis code-quality refactoring
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
github/gh-aw-mcpg#16716 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
github/gh-aw-mcpg#16714 ·
メンテナーはふだん 1 日以内に返信
github/gh-aw-mcpg の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
Docs: Recording rules pages don't say what happens to a recorded metric when its rule is deletedオープンinternal
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
jesseduffield/lazygit#6229 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
prometheus/prometheus#20482 ·
メンテナーはふだん 2 日以内に返信
-
Add iterate GmbH domains to a dedicated list and include it in company and developer categoriesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
v2fly/domain-list-community#4307 ·
メンテナーはふだん 1 日以内に返信