fix: resolve all clippy --all-targets warnings across 15 files

- gateway/mod.rs: move send_json before test module (items_after_test_module)
- memory/vector.rs: fix float_cmp, cast_precision_loss, approx_constant
- memory/chunker.rs: fix format_collect, format_push_string, write_with_newline
- memory/sqlite.rs: fix useless_vec
- heartbeat/engine.rs: fix format_collect, write_with_newline
- config/schema.rs: fix needless_raw_string_hashes
- tools/composio.rs: fix needless_raw_string_hashes
- integrations/registry.rs: fix uninlined_format_args, unused import
- tunnel/mod.rs: fix doc_markdown
- skills/mod.rs: allow similar_names in test module
- channels/cli.rs: fix unreadable_literal
- observability/mod.rs: fix manual_string_new
- runtime/mod.rs: fix manual_string_new
- examples/custom_memory.rs: add Default impl (new_without_default)
- examples/custom_channel.rs: fix needless_borrows_for_generic_args
This commit is contained in:
argenis de la rosa 2026-02-14 03:52:57 -05:00
parent 18582fe9c8
commit 1fd51f1984
15 changed files with 82 additions and 49 deletions

View file

@ -206,9 +206,14 @@ mod tests {
#[test]
fn respects_max_tokens() {
// Build multi-line text (one sentence per line) to exercise line-level splitting
let long_text: String = (0..200)
.map(|i| format!("This is sentence number {i} with some extra words to fill it up.\n"))
.collect();
let long_text: String = (0..200).fold(String::new(), |mut s, i| {
use std::fmt::Write;
let _ = writeln!(
s,
"This is sentence number {i} with some extra words to fill it up."
);
s
});
let chunks = chunk_markdown(&long_text, 50); // 50 tokens ≈ 200 chars
assert!(
chunks.len() > 1,
@ -229,7 +234,8 @@ mod tests {
fn preserves_heading_in_split_sections() {
let mut text = String::from("## Big Section\n");
for i in 0..100 {
text.push_str(&format!("Line {i} with some content here.\n\n"));
use std::fmt::Write;
let _ = write!(text, "Line {i} with some content here.\n\n");
}
let chunks = chunk_markdown(&text, 50);
assert!(chunks.len() > 1);
@ -355,7 +361,11 @@ mod tests {
fn no_content_loss() {
let text = "# A\nContent A line 1\nContent A line 2\n\n## B\nContent B\n\n## C\nContent C";
let chunks = chunk_markdown(text, 512);
let reassembled: String = chunks.iter().map(|c| format!("{}\n", c.content)).collect();
let reassembled: String = chunks.iter().fold(String::new(), |mut s, c| {
use std::fmt::Write;
let _ = writeln!(s, "{}", c.content);
s
});
// All original content words should appear
for word in ["Content", "line", "1", "2"] {
assert!(

View file

@ -763,7 +763,7 @@ mod tests {
#[tokio::test]
async fn sqlite_category_roundtrip() {
let (_tmp, mem) = temp_sqlite();
let categories = vec![
let categories = [
MemoryCategory::Core,
MemoryCategory::Daily,
MemoryCategory::Conversation,

View file

@ -132,6 +132,12 @@ pub fn hybrid_merge(
}
#[cfg(test)]
#[allow(
clippy::float_cmp,
clippy::approx_constant,
clippy::cast_precision_loss,
clippy::cast_possible_truncation
)]
mod tests {
use super::*;
@ -271,13 +277,15 @@ mod tests {
let b = vec![-1.0, 0.0];
// Cosine = -1.0, clamped to 0.0
let sim = cosine_similarity(&a, &b);
assert_eq!(sim, 0.0);
assert!(sim.abs() < f32::EPSILON);
}
#[test]
fn cosine_high_dimensional() {
let a: Vec<f32> = (0..1536).map(|i| (i as f32) * 0.001).collect();
let b: Vec<f32> = (0..1536).map(|i| (i as f32) * 0.001 + 0.0001).collect();
let a: Vec<f32> = (0..1536).map(|i| (f64::from(i) * 0.001) as f32).collect();
let b: Vec<f32> = (0..1536)
.map(|i| (f64::from(i) * 0.001 + 0.0001) as f32)
.collect();
let sim = cosine_similarity(&a, &b);
assert!(
sim > 0.99,
@ -288,14 +296,14 @@ mod tests {
#[test]
fn cosine_single_element() {
assert!((cosine_similarity(&[5.0], &[5.0]) - 1.0).abs() < 0.001);
assert_eq!(cosine_similarity(&[5.0], &[-5.0]), 0.0);
assert!(cosine_similarity(&[5.0], &[-5.0]).abs() < f32::EPSILON);
}
#[test]
fn cosine_both_zero_vectors() {
let a = vec![0.0, 0.0];
let b = vec![0.0, 0.0];
assert_eq!(cosine_similarity(&a, &b), 0.0);
assert!(cosine_similarity(&a, &b).abs() < f32::EPSILON);
}
// ── Edge cases: vec↔bytes serialization ──────────────────────
@ -306,7 +314,7 @@ mod tests {
let bytes = vec![0u8, 0, 0, 0, 0xFF];
let result = bytes_to_vec(&bytes);
assert_eq!(result.len(), 1);
assert_eq!(result[0], 0.0);
assert!(result[0].abs() < f32::EPSILON);
}
#[test]
@ -351,7 +359,7 @@ mod tests {
let merged = hybrid_merge(&vec_results, &kw_results, 0.0, 0.0, 10);
// All final scores should be 0.0
for r in &merged {
assert_eq!(r.final_score, 0.0);
assert!(r.final_score.abs() < f32::EPSILON);
}
}