huginn-daemon: clippy-clean under -D warnings
Unused import, sort_by_key, redundant closure, useless vec!, identical if branches, assert!(bool), a never-read test field, and a Collected alias for the huginn-sources option pair. No behaviour change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a424c1c4d5
commit
522c810e28
4 changed files with 14 additions and 13 deletions
|
|
@ -58,8 +58,11 @@ enum Stop {
|
|||
Locked,
|
||||
}
|
||||
|
||||
/// The single-valued options and the repeated ones, by name.
|
||||
type Collected = (BTreeMap<String, String>, BTreeMap<String, Vec<String>>);
|
||||
|
||||
/// The options named, each once, except those in `repeated`, which keep every value.
|
||||
fn collect(args: impl Iterator<Item = String>, once: &[&str], repeated: &[&str]) -> Result<(BTreeMap<String, String>, BTreeMap<String, Vec<String>>)> {
|
||||
fn collect(args: impl Iterator<Item = String>, once: &[&str], repeated: &[&str]) -> Result<Collected> {
|
||||
let mut args = args;
|
||||
let mut singles = BTreeMap::new();
|
||||
let mut many: BTreeMap<String, Vec<String>> = BTreeMap::new();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use cultnet_rs::{
|
|||
decode_cultnet_message_from_slice, encode_cultnet_message_to_vec, encode_frame,
|
||||
};
|
||||
use huginn_mind::desk_wire::{
|
||||
DESK_MAX_RESPONSE_BYTES, DESK_REQUEST_SCHEMA, DESK_SERVICE_ID, DeskRequest, DeskResponse, ForkAnswer, ForkAnswerCode, ForkAnswerRequest, ForkCursor,
|
||||
DESK_REQUEST_SCHEMA, DESK_SERVICE_ID, DeskRequest, DeskResponse, ForkAnswer, ForkAnswerCode, ForkAnswerRequest, ForkCursor,
|
||||
ForkEntry, ForkLimit, ForkList, ListStatus, RequestSchema,
|
||||
};
|
||||
use huginn_mind::envelope::{OperationFailure, decode_desk_response, decode_response, encode_desk_request, encode_request};
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ impl HttpForge {
|
|||
capped.push(repo.clone());
|
||||
}
|
||||
}
|
||||
events.sort_by(|a, b| b.id.cmp(&a.id));
|
||||
events.sort_by_key(|event| std::cmp::Reverse(event.id));
|
||||
// The cursor never moves backwards: a read that saw nothing new keeps the one it was given.
|
||||
head = head.max(after.unwrap_or(0));
|
||||
let (mut open_prs, mut unseen) = (Vec::new(), dark.clone());
|
||||
|
|
@ -251,7 +251,7 @@ fn redirect_target(base: &str, location: &str) -> Option<OrgRepo> {
|
|||
let at = segments.windows(3).position(|window| window == ["api", "v1", "repos"])?;
|
||||
let plain = |segment: &&str| !segment.is_empty() && *segment != "." && *segment != ".." && segment.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'));
|
||||
let [owner, name, "activities", "feeds"] = segments[at + 3..] else { return None };
|
||||
if !segments[..at].iter().all(|segment| plain(segment)) || !plain(&owner) || !plain(&name) {
|
||||
if !segments[..at].iter().all(plain) || !plain(&owner) || !plain(&name) {
|
||||
return None;
|
||||
}
|
||||
let repo = OrgRepo(format!("{owner}/{name}"));
|
||||
|
|
@ -583,9 +583,9 @@ mod tests {
|
|||
let mut first_page: Vec<Value> = (0..PAGE as u32).map(|n| pr(n + 100, "kiko", "GameCult/Elsewhere")).collect();
|
||||
first_page[0] = pr(8, "nibu", "GameCult/Ratatoskr");
|
||||
first_page[1] = pr(42, "Eureka", "GameCult/Eureka");
|
||||
let search = vec![Value::Array(first_page).to_string(), Value::Array(vec![pr(9, "void", "GameCult/Huginn")]).to_string()];
|
||||
let search = [Value::Array(first_page).to_string(), Value::Array(vec![pr(9, "void", "GameCult/Huginn")]).to_string()];
|
||||
let names: Vec<Value> = (0..61).map(|n| json!({ "full_name": match n { 0 => "GameCult/ratatoskr".to_owned(), 1 => "GameCult/Huginn".to_owned(), n => format!("GameCult/r{n}") } })).collect();
|
||||
let listing = vec![Value::Array(names[..PAGE].to_vec()).to_string(), Value::Array(names[PAGE..].to_vec()).to_string()];
|
||||
let listing = [Value::Array(names[..PAGE].to_vec()).to_string(), Value::Array(names[PAGE..].to_vec()).to_string()];
|
||||
let sample = sample();
|
||||
let (base, asked) = forge_of(move |path| {
|
||||
if is_feed(path) && path.contains("/GameCult/Ghost/") {
|
||||
|
|
@ -626,7 +626,7 @@ mod tests {
|
|||
let full = |from: u32| Value::Array((0..PAGE as u32).map(|n| pr(from + n, "GameCult/Elsewhere")).collect()).to_string();
|
||||
let mut third: Vec<Value> = (0..PAGE as u32).map(|n| pr(300 + n, "GameCult/Elsewhere")).collect();
|
||||
third[PAGE - 1] = pr(7, "GameCult/Huginn");
|
||||
let search = vec![full(100), full(200), Value::Array(third).to_string(), "[]".to_owned()];
|
||||
let search = [full(100), full(200), Value::Array(third).to_string(), "[]".to_owned()];
|
||||
let (base, asked) = forge_of(move |path| {
|
||||
if is_feed(path) {
|
||||
Some("[]".to_owned())
|
||||
|
|
@ -746,9 +746,7 @@ mod tests {
|
|||
let (base, _) = forge_of(move |path| {
|
||||
if is_feed(path) && path.contains("/GameCult/cinny/") {
|
||||
Some(dark())
|
||||
} else if is_feed(path) {
|
||||
Some("[]".to_owned().into())
|
||||
} else if path.contains("/issues/search") {
|
||||
} else if is_feed(path) || path.contains("/issues/search") {
|
||||
Some("[]".to_owned().into())
|
||||
} else {
|
||||
Some(listing.clone().into())
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ fn a_full_run_over_a_fake_synapse() {
|
|||
let request = Purge::check("!swarm:s", "2026-11-10T00:00:00Z", "2026-11-11T00:00:00Z", "follow_up:x", now()).unwrap();
|
||||
assert_eq!(purge(&mut rig.index, &request).unwrap(), "chat-purge requested: !swarm:s 2026-11-10T00:00:00Z..2026-11-11T00:00:00Z request=\"follow_up:x\" windows=1");
|
||||
let before = rig.index.cursors();
|
||||
assert_eq!(purge(&mut rig.index, &request).unwrap().ends_with("windows=1"), true);
|
||||
assert!(purge(&mut rig.index, &request).unwrap().ends_with("windows=1"));
|
||||
assert_eq!(rig.index.cursors(), before, "a repeated request writes nothing");
|
||||
let secret = format!("key ghp_{}", "k2L9".repeat(9));
|
||||
{
|
||||
|
|
@ -231,7 +231,7 @@ fn a_request_cannot_forge_a_journal_line() {
|
|||
#[test]
|
||||
fn a_failed_room_report_goes_to_the_complaint_stream_and_fails_the_run() {
|
||||
let mut rig = Rig::new();
|
||||
struct FactsDown(Rooms);
|
||||
struct FactsDown;
|
||||
impl RoomHistory for FactsDown {
|
||||
fn joined_rooms(&mut self) -> Result<Vec<String>> {
|
||||
Ok(vec!["!swarm:s".to_owned()])
|
||||
|
|
@ -243,7 +243,7 @@ fn a_failed_room_report_goes_to_the_complaint_stream_and_fails_the_run() {
|
|||
bail!("unreachable")
|
||||
}
|
||||
}
|
||||
let out = rig.go(Some(&mut FactsDown(rooms(vec![]))));
|
||||
let out = rig.go(Some(&mut FactsDown));
|
||||
assert_eq!(out.status, 1);
|
||||
assert!(out.complained.iter().any(|line| line.contains("!swarm:s") && line.contains("facts are down")), "{:?}", out.complained);
|
||||
assert!(!out.said.iter().any(|line| line.contains("facts are down")), "{:?}", out.said);
|
||||
|
|
|
|||
Loading…
Reference in a new issue