fix(#999): resolve all clippy warnings across the workspace
All crates now pass `cargo clippy --workspace -- -D warnings` cleanly.
Fixes span six crates (hive-sh4re, hive-ag3nt, hive-c0re, hive-forge,
hive-priv, hive-matrix-mcp was already clean):
- doc_markdown: wrap snake_case, type names, constants in backticks
- collapsible_if / collapsible_match: fold nested ifs into let-chains
- duration_suboptimal_units: Duration::from_secs(N) → from_mins/from_hours
- implicit_hasher: allow on HashMap-param fns where generalization is risky
- items_after_statements: hoist use to function tops
- map(f).unwrap_or(x) → map_or(x, f); map(f).unwrap_or_else(g) → map_or_else
- is_ok_and / is_none_or in place of map().unwrap_or(bool)
- needless_continue: {} instead of continue in loop match arms
- match_same_arms: Ok(None) | Err(_) merged
- format_push_str: write!() instead of push_str(&format!())
- while let replaces loop { let Some(..) = x else { break } }
- struct_excessive_bools / dead_code: allow on purpose-built structs
- too_many_lines / too_many_arguments: allow where refactor not worth it
- unused_async: remove async from poll_once in bash_runner
- needless_borrow: fix &repo deref in hive-forge comments verb
- cast_possible_truncation: allow u64→usize in fetch_tail
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
9efe9ca175
commit
5c5ca38fe8
32 changed files with 121 additions and 127 deletions
|
|
@ -48,8 +48,8 @@ pub struct Args {
|
|||
pub fn run(client: &Client, args: Args) -> Result<()> {
|
||||
let repo = client.repo();
|
||||
let comments = match args.tail {
|
||||
Some(n) => fetch_tail(client, &repo, args.number, n)?,
|
||||
None => fetch_head(client, &repo, args.number, args.limit)?,
|
||||
Some(n) => fetch_tail(client, repo, args.number, n)?,
|
||||
None => fetch_head(client, repo, args.number, args.limit)?,
|
||||
};
|
||||
if client.json_mode() {
|
||||
let trimmed: Vec<Value> = comments
|
||||
|
|
@ -99,6 +99,7 @@ fn fetch_head(client: &Client, repo: &str, number: u64, limit: u64) -> Result<Ve
|
|||
/// first to know how many exist, then start paginating from the
|
||||
/// page that contains item `total - n`. Work is bounded by
|
||||
/// `ceil(n/50) + 1` page fetches, regardless of thread length.
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
fn fetch_tail(client: &Client, repo: &str, number: u64, n: usize) -> Result<Vec<Value>> {
|
||||
if n == 0 {
|
||||
return Ok(Vec::new());
|
||||
|
|
|
|||
|
|
@ -144,8 +144,7 @@ fn parse_diff_git_path(rest: &str) -> Option<String> {
|
|||
// containing `"` doesn't terminate early).
|
||||
let mut iter = after_open.char_indices();
|
||||
let mut a_close = None;
|
||||
loop {
|
||||
let Some((i, c)) = iter.next() else { break };
|
||||
while let Some((i, c)) = iter.next() {
|
||||
if c == '\\' {
|
||||
// Skip the next char — it's part of the escape.
|
||||
iter.next();
|
||||
|
|
@ -167,8 +166,7 @@ fn parse_diff_git_path(rest: &str) -> Option<String> {
|
|||
// Find b-side's closing quote with the same escape rule.
|
||||
let mut iter = b_inside.char_indices();
|
||||
let mut b_close = None;
|
||||
loop {
|
||||
let Some((i, c)) = iter.next() else { break };
|
||||
while let Some((i, c)) = iter.next() {
|
||||
if c == '\\' {
|
||||
iter.next();
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
//! second of the four #694 gaps (read-side; no boundary concerns —
|
||||
//! every agent + the operator queries the issue tracker constantly).
|
||||
|
||||
use std::fmt::Write as _;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::{Args as ClapArgs, ValueEnum};
|
||||
use serde_json::Value;
|
||||
|
|
@ -97,24 +99,24 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
|||
if let Some(u) = args.assignee.as_deref()
|
||||
&& !u.is_empty()
|
||||
{
|
||||
path.push_str(&format!("&assigned_by={}", pct_encode(u)));
|
||||
write!(path, "&assigned_by={}", pct_encode(u)).unwrap();
|
||||
}
|
||||
if let Some(u) = args.author.as_deref()
|
||||
&& !u.is_empty()
|
||||
{
|
||||
path.push_str(&format!("&created_by={}", pct_encode(u)));
|
||||
write!(path, "&created_by={}", pct_encode(u)).unwrap();
|
||||
}
|
||||
if let Some(u) = args.mention.as_deref()
|
||||
&& !u.is_empty()
|
||||
{
|
||||
path.push_str(&format!("&mentioned_by={}", pct_encode(u)));
|
||||
write!(path, "&mentioned_by={}", pct_encode(u)).unwrap();
|
||||
}
|
||||
if !args.labels.is_empty() {
|
||||
// Encode each label individually so a comma INSIDE a label
|
||||
// (rare but legal) gets escaped while the field separator
|
||||
// stays a literal comma the forge will parse as N labels.
|
||||
let encoded: Vec<String> = args.labels.iter().map(|l| pct_encode(l)).collect();
|
||||
path.push_str(&format!("&labels={}", encoded.join(",")));
|
||||
write!(path, "&labels={}", encoded.join(",")).unwrap();
|
||||
}
|
||||
let resp = client.get_json(&path)?;
|
||||
if client.json_mode() {
|
||||
|
|
@ -143,7 +145,7 @@ fn pct_encode(s: &str) -> String {
|
|||
if b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_' | b'.' | b'~') {
|
||||
out.push(b as char);
|
||||
} else {
|
||||
out.push_str(&format!("%{b:02X}"));
|
||||
write!(out, "%{b:02X}").unwrap();
|
||||
}
|
||||
}
|
||||
out
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
//!
|
||||
//! Forgejo's `/issues/{n}/timeline` endpoint returns BOTH the actual
|
||||
//! comments AND the event entries (label, assignee, close, reopen,
|
||||
//! pull_push, etc.) in chronological order. We render each row in
|
||||
//! `pull_push`, etc.) in chronological order. We render each row in
|
||||
//! a human-readable form by default; pass the global `--json` flag
|
||||
//! for the raw API shape.
|
||||
//!
|
||||
|
|
@ -62,6 +62,7 @@ pub fn run(client: &Client, args: Args) -> Result<()> {
|
|||
/// output for every supported event type without re-implementing the
|
||||
/// per-arm dispatch. `print_event` is the only caller that adds the
|
||||
/// terminating newline.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn format_event(ev: &Value) -> String {
|
||||
let event_type = ev.get("type").and_then(Value::as_str).unwrap_or("?");
|
||||
let user = ev
|
||||
|
|
|
|||
Loading…
Reference in a new issue