From c9c70f9ff2d7ffa5ba3f85607ffe3336fc754b02 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 29 Jul 2026 17:23:06 +0000 Subject: [PATCH] style(clippy): group shared args into PrVoteCtx in submit_pr_review.rs Both check_self_approval and submit_vote had 8 parameters, exceeding clippy::too_many_arguments limit of 7. Introduce a private PrVoteCtx struct to bundle the five shared fields (client, base_url, encoded_repo, pull_request_id, token), reducing each function to four parameters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/safe_outputs/submit_pr_review.rs | 57 ++++++++++++++++++---------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/src/safe_outputs/submit_pr_review.rs b/src/safe_outputs/submit_pr_review.rs index 8c63d6f4..6c5294cb 100644 --- a/src/safe_outputs/submit_pr_review.rs +++ b/src/safe_outputs/submit_pr_review.rs @@ -168,18 +168,31 @@ async fn fetch_authenticated_user_id( Ok(Ok(user_id)) } +/// Shared context for ADO PR vote API calls. +struct PrVoteCtx<'a> { + client: &'a reqwest::Client, + base_url: &'a str, + encoded_repo: &'a str, + pull_request_id: i32, + token: &'a str, +} + /// Self-approval guard: returns `Some(failure)` when a positive vote targets a PR the /// authenticated user created; returns `None` when the vote is allowed to proceed. async fn check_self_approval( - client: &reqwest::Client, - base_url: &str, - encoded_repo: &str, - pull_request_id: i32, + ctx: &PrVoteCtx<'_>, user_id: &str, event: &str, vote_value: i32, - token: &str, ) -> anyhow::Result> { + let PrVoteCtx { + client, + base_url, + encoded_repo, + pull_request_id, + token, + } = ctx; + let pull_request_id = *pull_request_id; if vote_value <= 0 { return Ok(None); } @@ -231,15 +244,19 @@ async fn check_self_approval( /// PUTs the review vote to the ADO reviewers endpoint. /// Returns `Err` on network errors, `Ok(Some(failure))` on HTTP errors, `Ok(None)` on success. async fn submit_vote( - client: &reqwest::Client, - base_url: &str, - encoded_repo: &str, + ctx: &PrVoteCtx<'_>, encoded_user_id: &str, - pull_request_id: i32, event: &str, vote_value: i32, - token: &str, ) -> anyhow::Result> { + let PrVoteCtx { + client, + base_url, + encoded_repo, + pull_request_id, + token, + } = ctx; + let pull_request_id = *pull_request_id; let vote_url = format!( "{}/{}/pullRequests/{}/reviewers/{}?api-version=7.1", base_url, encoded_repo, pull_request_id, encoded_user_id @@ -427,16 +444,20 @@ impl Executor for SubmitPrReviewResult { Err(failure) => return Ok(failure), }; + let vote_ctx = PrVoteCtx { + client: &client, + base_url: &base_url, + encoded_repo: &encoded_repo, + pull_request_id: self.pull_request_id, + token, + }; + // Self-approval guard: prevent the agent from approving PRs it created. if let Some(failure) = check_self_approval( - &client, - &base_url, - &encoded_repo, - self.pull_request_id, + &vote_ctx, &user_id, &self.event, vote_value, - token, ) .await? { @@ -446,14 +467,10 @@ impl Executor for SubmitPrReviewResult { // PUT vote to reviewers endpoint let encoded_user_id = utf8_percent_encode(&user_id, PATH_SEGMENT).to_string(); if let Some(failure) = submit_vote( - &client, - &base_url, - &encoded_repo, + &vote_ctx, &encoded_user_id, - self.pull_request_id, &self.event, vote_value, - token, ) .await? {