fix(clippy): fix all clippy warnings in hive-ag3nt, hive-forge, hive-matrix-mcp, hive-sh4re
Fixes all clippy -D warnings errors in the crates iris owns: hive-sh4re: - doc_lazy_continuation: add blank /// separator in priv_proto.rs - doc_markdown: backtick PRIVATE_NETWORK=0 / PRIVATE_NETWORK=1 hive-matrix-mcp: - map_unwrap_or: map().unwrap_or_else() -> map_or_else() in paths.rs - collapsible_if: if-let chains in wake.rs - doc_markdown: backtick M_UNKNOWN_TOKEN in main.rs - cast_possible_truncation: usize/u64 -> u32::try_from in handlers.rs - map_unwrap_or: map_or_else() in handlers.rs - manual_let_else: match Ok(r) => r, Err => return -> let Ok in handlers.rs - unused_async: remove async from list_invites; update socket.rs call site hive-forge: - doc_markdown: backtick REQUEST_CHANGES / APPROVED / COMMENT in pr_reviews.rs - unnecessary_wraps: list_reviews_text returns () not Result<()> - doc_markdown: backtick start_page / last_page in comments.rs - cast_possible_truncation: PAGE_SIZE u64 -> usize; remove as usize casts hive-ag3nt: - collapsible_if: if-let chains in events.rs and mcp.rs - single_match_else: match -> if let in events.rs and mcp.rs - items_after_statements: hoist STATUS_MAX_CHARS const in mcp.rs - map_unwrap_or: map_or_else() in mcp.rs and mcp_loose_ends.rs - cast_possible_truncation: usize -> u32::try_from in mcp.rs - doc_markdown: backtick snake_case in mcp.rs, needs_update/deployed_sha in web_ui.rs, HISTORY_CAPACITY in web_ui.rs - identical_match_arms: combine manage_root_agent | query_agent_state - redundant_closure: |s| s.to_string() -> ToString::to_string in web_ui.rs - duration_suboptimal_units: from_secs(3600) -> from_hours(1) in turn.rs Remaining failures in hive-c0re (39), hive-priv (8), hive-bash-mcp (11) are owned by damocles.
This commit is contained in:
parent
6a35f48458
commit
92b32d06fb
13 changed files with 128 additions and 133 deletions
|
|
@ -26,7 +26,7 @@ use crate::verbs::print_json;
|
|||
/// Forgejo's per-page comment cap. The API caps `limit` at 50 even
|
||||
/// if a higher value is requested; pin it explicitly so the math
|
||||
/// downstream doesn't depend on a hidden default.
|
||||
const PAGE_SIZE: u64 = 50;
|
||||
const PAGE_SIZE: usize = 50;
|
||||
|
||||
#[derive(ClapArgs)]
|
||||
pub struct Args {
|
||||
|
|
@ -112,7 +112,7 @@ fn fetch_tail(client: &Client, repo: &str, number: u64, n: usize) -> Result<Vec<
|
|||
// Cap `n` at the actual total so the math below stays in range
|
||||
// when the caller asks for more comments than exist.
|
||||
let n = n.min(total);
|
||||
let page_size = PAGE_SIZE as usize;
|
||||
let page_size = PAGE_SIZE;
|
||||
// 0-based index of the first comment we want; integer-divide to
|
||||
// get the 1-based page that contains it.
|
||||
let start_idx = total - n;
|
||||
|
|
@ -145,12 +145,12 @@ mod tests {
|
|||
|
||||
/// Pure helper mirroring the page-arithmetic in `fetch_tail`:
|
||||
/// given a total comment count + requested tail size, return
|
||||
/// the (start_page, last_page) pair the network loop would
|
||||
/// the (`start_page`, `last_page`) pair the network loop would
|
||||
/// walk. Lets us pin the pagination plan — the part that's
|
||||
/// easy to off-by-one — without touching the network.
|
||||
fn tail_plan(total: usize, n: usize) -> (usize, usize) {
|
||||
let n = n.min(total);
|
||||
let page_size = PAGE_SIZE as usize;
|
||||
let page_size = PAGE_SIZE;
|
||||
let start_idx = total - n;
|
||||
let start_page = (start_idx / page_size) + 1;
|
||||
let last_page = (total - 1) / page_size + 1;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub struct Args {
|
|||
#[arg(long, conflicts_with_all = ["request_changes", "comment"])]
|
||||
approve: bool,
|
||||
|
||||
/// Request changes on the PR (submit a REQUEST_CHANGES review).
|
||||
/// Request changes on the PR (submit a `REQUEST_CHANGES` review).
|
||||
#[arg(long, conflicts_with_all = ["approve", "comment"])]
|
||||
request_changes: bool,
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Submit a review event (APPROVED / REQUEST_CHANGES / COMMENT) and print
|
||||
/// Submit a review event (`APPROVED` / `REQUEST_CHANGES` / `COMMENT`) and print
|
||||
/// a compact summary of the created review.
|
||||
fn submit_review(client: &Client, number: u64, event: &str, body: Option<String>) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
|
|
@ -89,7 +89,8 @@ fn list_reviews(client: &Client, number: u64) -> Result<()> {
|
|||
if client.json_mode() {
|
||||
list_reviews_json(client, repo, number, &reviews)
|
||||
} else {
|
||||
list_reviews_text(client, repo, number, &reviews)
|
||||
list_reviews_text(client, repo, number, &reviews);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -129,10 +130,10 @@ fn list_reviews_json(client: &Client, repo: &str, number: u64, reviews: &[Value]
|
|||
|
||||
/// Human-readable output: Markdown-style heading per review, inline
|
||||
/// comments as `[path:line] body` (line omitted for PR-level comments).
|
||||
fn list_reviews_text(client: &Client, repo: &str, number: u64, reviews: &[Value]) -> Result<()> {
|
||||
fn list_reviews_text(client: &Client, repo: &str, number: u64, reviews: &[Value]) {
|
||||
if reviews.is_empty() {
|
||||
println!("(no reviews)");
|
||||
return Ok(());
|
||||
return;
|
||||
}
|
||||
for r in reviews {
|
||||
let id = r.get("id").and_then(Value::as_u64).unwrap_or(0);
|
||||
|
|
@ -160,5 +161,4 @@ fn list_reviews_text(client: &Client, repo: &str, number: u64, reviews: &[Value]
|
|||
}
|
||||
println!();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue