From b0507a093651cd1bf76f18c8f4d0a99f59224f21 Mon Sep 17 00:00:00 2001 From: atlas Date: Wed, 2 Sep 2026 11:22:42 +0200 Subject: [PATCH] hive-forge: move the lint test module to the end of the file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clippy::items_after_test_module (pedantic, denied) — a #[cfg(test)] mod has to be the last item in its file. Pure move: same line count, same line multiset, no content change. `cargo test` was green while this was broken; only clippy saw it. --- hive-forge/src/verbs/lint.rs | 76 ++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/hive-forge/src/verbs/lint.rs b/hive-forge/src/verbs/lint.rs index 4ba7a0d4..4df42ef3 100644 --- a/hive-forge/src/verbs/lint.rs +++ b/hive-forge/src/verbs/lint.rs @@ -497,6 +497,36 @@ fn num(it: &Value) -> i64 { it.get("number").and_then(Value::as_i64).unwrap_or(0) } +fn title(it: &Value) -> &str { + it.get("title").and_then(Value::as_str).unwrap_or("") +} + +fn kind_label(it: &Value) -> &'static str { + if it.get("is_pr").and_then(Value::as_bool).unwrap_or(false) { + "pr" + } else { + "issue" + } +} + +/// Either pretty-print the JSON array (when --json) or fall back to a +/// caller-supplied human one-liner per item. +fn emit(client: &Client, items: &[Value], fmt: F) -> Result<()> +where + F: Fn(&Value) -> String, +{ + if client.json_mode() { + print_json(&Value::Array(items.to_vec())) + } else { + if items.is_empty() { + println!("(no matches)"); + } + for it in items { + println!("{}", fmt(it)); + } + Ok(()) + } +} #[cfg(test)] mod tests { use super::*; @@ -529,7 +559,10 @@ mod tests { ); let unset = issue(json!({ "labels": [{ "name": "area/ops" }] })); - assert!(!has_scoped_label(&unset, "area/"), "absent means not exclusive"); + assert!( + !has_scoped_label(&unset, "area/"), + "absent means not exclusive" + ); } /// The caller builds the prefix as `"/"`, which is what stops @@ -567,7 +600,10 @@ mod tests { // `deserialize_with`, so serde requires it to be present even though // its type is `Option`. The forge sends the key with a null value. let absent = pull(json!({ "requested_reviewers": null })); - assert!(!has_requested_reviewer(&absent, None), "null is not a reviewer"); + assert!( + !has_requested_reviewer(&absent, None), + "null is not a reviewer" + ); } #[test] @@ -641,7 +677,10 @@ mod tests { State::Closed.issue_state(), IssueListIssuesQueryState::Closed )); - assert!(matches!(State::All.issue_state(), IssueListIssuesQueryState::All)); + assert!(matches!( + State::All.issue_state(), + IssueListIssuesQueryState::All + )); assert!(matches!( State::Open.pull_state(), RepoListPullRequestsQueryState::Open @@ -656,34 +695,3 @@ mod tests { )); } } - -fn title(it: &Value) -> &str { - it.get("title").and_then(Value::as_str).unwrap_or("") -} - -fn kind_label(it: &Value) -> &'static str { - if it.get("is_pr").and_then(Value::as_bool).unwrap_or(false) { - "pr" - } else { - "issue" - } -} - -/// Either pretty-print the JSON array (when --json) or fall back to a -/// caller-supplied human one-liner per item. -fn emit(client: &Client, items: &[Value], fmt: F) -> Result<()> -where - F: Fn(&Value) -> String, -{ - if client.json_mode() { - print_json(&Value::Array(items.to_vec())) - } else { - if items.is_empty() { - println!("(no matches)"); - } - for it in items { - println!("{}", fmt(it)); - } - Ok(()) - } -}