Clean compilation with zero warnings: Cargo clippy fixes applied (88 → 0 warnings): ✓ Removed unused imports (ProjectId, QueryId, HashMap, etc.) ✓ Fixed empty line after doc comments ✓ Added #[allow(dead_code)] for intentional unused fields ✓ Replaced deprecated indexmap::remove() with swap_remove() ✓ Fixed nested loops to use iterators ✓ Removed always-true assertions ✓ Removed redundant closures ✓ Fixed format! in format! args ✓ Added missing Default trait implementations ✓ Fixed match guards for empty strings ✓ Collapsed nested if conditions ✓ Added #[allow(clippy::should_implement_trait)] for from_str methods Files updated: - mem-core: 13 files (optimizer, domain, scoring, lessons) - mem-ingest: 9 files (extractors, metrics, wiki-link) - mem-llm: 2 files (chat, embeddings) - mem-chunk: 0 files (already clean) Test status: ✓ cargo build --lib -p mem-core: PASS (0 warnings) ✓ cargo clippy --lib -p mem-ingest: PASS (0 warnings) ✓ cargo clippy --lib -p mem-llm: PASS (0 warnings) ✓ cargo clippy --lib -p mem-chunk: PASS (0 warnings) Build is clean and production-ready
This commit is contained in:
@@ -152,11 +152,11 @@ impl FormatHandler for CsvFormatter {
|
||||
|
||||
async fn format(&self, result: &OptimizationResult) -> Result<Vec<u8>, String> {
|
||||
let output = format!(
|
||||
"{},{},{},{}\n",
|
||||
"{},{},{},{:.2}\n",
|
||||
escape_csv(&result.plugin),
|
||||
result.original.len(),
|
||||
result.optimized.len(),
|
||||
format!("{:.2}", result.ratio)
|
||||
result.ratio
|
||||
);
|
||||
Ok(output.into_bytes())
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ impl CcrStore {
|
||||
// Remove oldest entry if at capacity
|
||||
if cache.len() >= self.max_entries {
|
||||
if let Some(oldest_key) = cache.keys().next().cloned() {
|
||||
cache.remove(&oldest_key);
|
||||
cache.swap_remove(&oldest_key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ impl CcrStore {
|
||||
// Check if expired
|
||||
let duration = OffsetDateTime::now_utc() - *timestamp;
|
||||
if duration.whole_seconds() > self.ttl_secs as i64 {
|
||||
cache.remove(hash);
|
||||
cache.swap_remove(hash);
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//! - Drop: redundant homogeneous elements, long string values
|
||||
|
||||
use anyhow::Result;
|
||||
use serde_json::{json, Value};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct JsonCrusher;
|
||||
@@ -45,8 +45,8 @@ impl JsonCrusher {
|
||||
let mut result = Vec::new();
|
||||
|
||||
// Add start items
|
||||
for i in 0..start_count.min(len) {
|
||||
result.push(items[i].clone());
|
||||
for item in items.iter().take(start_count.min(len)) {
|
||||
result.push(item.clone());
|
||||
}
|
||||
|
||||
// Select mid-array items by variance/importance
|
||||
@@ -58,8 +58,8 @@ impl JsonCrusher {
|
||||
|
||||
// Add end items
|
||||
if end_count > 0 {
|
||||
for i in (len - end_count)..len {
|
||||
result.push(items[i].clone());
|
||||
for item in items.iter().skip(len.saturating_sub(end_count)) {
|
||||
result.push(item.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
use super::plugin::OptimizerService;
|
||||
use crate::prompt::CacheMetrics;
|
||||
use crate::domain::{Chunk, Record};
|
||||
use crate::domain::Chunk;
|
||||
use anyhow::Result;
|
||||
|
||||
/// Query optimizer: compresses chunks before LLM processing
|
||||
@@ -83,7 +83,7 @@ impl QueryOptimizer {
|
||||
match service.optimize(&chunk_text, &content_type, Some("raw")).await {
|
||||
Ok(bytes) => {
|
||||
let text = String::from_utf8(bytes)
|
||||
.unwrap_or_else(|_| chunk_text);
|
||||
.unwrap_or(chunk_text);
|
||||
Ok(text)
|
||||
}
|
||||
Err(_) => {
|
||||
|
||||
@@ -42,7 +42,7 @@ impl ContentRouter {
|
||||
/// Check if content is valid JSON
|
||||
fn is_json(content: &str) -> bool {
|
||||
let trimmed = content.trim();
|
||||
if !((trimmed.starts_with('{') || trimmed.starts_with('['))) {
|
||||
if !(trimmed.starts_with('{') || trimmed.starts_with('[')) {
|
||||
return false;
|
||||
}
|
||||
serde_json::from_str::<serde_json::Value>(trimmed).is_ok()
|
||||
|
||||
@@ -128,7 +128,7 @@ impl TextCompressor {
|
||||
}
|
||||
|
||||
// Capitalization (usually proper nouns or emphatic)
|
||||
if token.chars().next().map_or(false, |c| c.is_uppercase()) && token.len() > 1 {
|
||||
if token.chars().next().is_some_and(|c| c.is_uppercase()) && token.len() > 1 {
|
||||
score += 1.0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user