diff --git a/Cargo.toml b/Cargo.toml index 7548e64..05ea2f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,3 +60,14 @@ state-machines = "0.2.0" [profile.dist] inherits = "release" lto = "thin" + +[workspace.lints.clippy] +perf = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } +nursery = { level = "warn", priority = -1 } +cargo = { level = "warn", priority = -1 } + +needless_question_mark = "allow" +single_call_fn = "allow" +must_use_candidate = "allow" + diff --git a/api-router/Cargo.toml b/api-router/Cargo.toml index 4d0e6e7..42665a4 100644 --- a/api-router/Cargo.toml +++ b/api-router/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" edition = "2021" license = "AGPL-3.0-or-later" +[lints] +workspace = true + [dependencies] tokio = { workspace = true } serde = { workspace = true } diff --git a/common/Cargo.toml b/common/Cargo.toml index a6092ab..fa3d1ab 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" edition = "2021" license = "AGPL-3.0-or-later" +[lints] +workspace = true + [dependencies] # Workspace dependencies tokio = { workspace = true } diff --git a/composite-retrieval/Cargo.toml b/composite-retrieval/Cargo.toml index 033a51b..54eb07d 100644 --- a/composite-retrieval/Cargo.toml +++ b/composite-retrieval/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" edition = "2021" license = "AGPL-3.0-or-later" +[lints] +workspace = true + [dependencies] tokio = { workspace = true } serde = { workspace = true } diff --git a/html-router/Cargo.toml b/html-router/Cargo.toml index fba9d7e..2503826 100644 --- a/html-router/Cargo.toml +++ b/html-router/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" edition = "2021" license = "AGPL-3.0-or-later" +[lints] +workspace = true + [dependencies] tokio = { workspace = true } serde = { workspace = true } diff --git a/html-router/src/routes/ingestion/handlers.rs b/html-router/src/routes/ingestion/handlers.rs index eb5765d..8168eaa 100644 --- a/html-router/src/routes/ingestion/handlers.rs +++ b/html-router/src/routes/ingestion/handlers.rs @@ -150,13 +150,8 @@ pub async fn get_task_updates_stream( let db = state.db.clone(); // 1. Check for authenticated user - let current_user = match auth.current_user { - Some(user) => user, - None => { - return Sse::new(create_error_stream( - "User not authenticated. Please log in.", - )); - } + let Some(current_user) = auth.current_user else { + return Sse::new(create_error_stream("User not authenticated")); }; // 2. Fetch task for initial authorization and to ensure it exists @@ -236,10 +231,10 @@ pub async fn get_task_updates_stream( Err(db_err) => { error!("Database error while fetching task '{}': {:?}", task_id, db_err); consecutive_db_errors += 1; - yield Ok(Event::default().event("error").data(format!("Temporary error fetching task update (attempt {}).", consecutive_db_errors))); + yield Ok(Event::default().event("error").data(format!("Temporary error fetching task update (attempt {consecutive_db_errors})."))); if consecutive_db_errors >= max_consecutive_db_errors { - error!("Max consecutive DB errors reached for task '{}'. Closing stream.", task_id); + error!("Max consecutive DB errors reached for task '{task_id}'. Closing stream."); yield Ok(Event::default().event("error").data("Persistent error fetching task updates. Stream closed.")); yield Ok(Event::default().event("close_stream").data("Stream complete")); break; @@ -257,14 +252,10 @@ pub async fn get_task_updates_stream( ) } Ok(None) => Sse::new(create_error_stream(format!( - "Task with ID '{}' not found.", - task_id + "Task with ID '{task_id}' not found." ))), Err(e) => { - error!( - "Failed to fetch task '{}' for authorization: {:?}", - task_id, e - ); + error!("Failed to fetch task '{task_id}' for authorization: {e:?}"); Sse::new(create_error_stream( "An error occurred while retrieving task details. Please try again later.", )) diff --git a/html-router/src/routes/knowledge/handlers.rs b/html-router/src/routes/knowledge/handlers.rs index 17abca9..892496f 100644 --- a/html-router/src/routes/knowledge/handlers.rs +++ b/html-router/src/routes/knowledge/handlers.rs @@ -90,10 +90,8 @@ pub async fn create_knowledge_entity( let description = form.description.trim().to_string(); let entity_type = KnowledgeEntityType::from(form.entity_type.trim().to_string()); - let embedding_input = format!( - "name: {}, description: {}, type: {:?}", - name, description, entity_type - ); + let embedding_input = + format!("name: {name}, description: {description}, type: {entity_type:?}"); let embedding = generate_embedding(&state.openai_client, &embedding_input, &state.db).await?; let source_id = format!("manual::{}", Uuid::new_v4()); @@ -126,7 +124,7 @@ pub async fn create_knowledge_entity( .collect(); let mut unique_ids: HashSet = HashSet::new(); - for target_id in form.relationship_ids.into_iter() { + for target_id in form.relationship_ids { if target_id == new_entity.id { continue; } @@ -333,7 +331,7 @@ async fn build_knowledge_base_data( if encoded.is_empty() { String::new() } else { - format!("&{}", encoded) + format!("&{encoded}") } }; @@ -662,7 +660,7 @@ pub async fn get_knowledge_graph_json( let mut degree_count: HashMap = HashMap::new(); let mut links: Vec = Vec::new(); - for rel in relationships.iter() { + for rel in &relationships { if entity_ids.contains(&rel.in_) && entity_ids.contains(&rel.out) { // undirected counting for degree *degree_count.entry(rel.in_.clone()).or_insert(0) += 1; @@ -689,17 +687,14 @@ pub async fn get_knowledge_graph_json( } // Normalize filter parameters: convert empty strings or "none" (case-insensitive) to None fn normalize_filter(input: Option) -> Option { - match input { - None => None, - Some(s) => { - let trimmed = s.trim(); - if trimmed.is_empty() || trimmed.eq_ignore_ascii_case("none") { - None - } else { - Some(trim_matching_quotes(trimmed).to_string()) - } + input.and_then(|s| { + let trimmed = s.trim(); + if trimmed.is_empty() || trimmed.eq_ignore_ascii_case("none") { + None + } else { + Some(trim_matching_quotes(trimmed).to_string()) } - } + }) } fn trim_matching_quotes(value: &str) -> &str { @@ -739,8 +734,8 @@ pub async fn show_edit_knowledge_entity_form( "knowledge/edit_knowledge_entity_modal.html", EntityData { entity, - user, entity_types, + user, }, )) } diff --git a/html-router/src/utils/pagination.rs b/html-router/src/utils/pagination.rs index 7845f0c..adcf49c 100644 --- a/html-router/src/utils/pagination.rs +++ b/html-router/src/utils/pagination.rs @@ -16,7 +16,7 @@ pub struct Pagination { } impl Pagination { - pub fn new( + pub const fn new( current_page: usize, per_page: usize, total_items: usize, diff --git a/ingestion-pipeline/Cargo.toml b/ingestion-pipeline/Cargo.toml index 3ba2831..68cbd28 100644 --- a/ingestion-pipeline/Cargo.toml +++ b/ingestion-pipeline/Cargo.toml @@ -4,6 +4,9 @@ version = "0.1.0" edition = "2021" license = "AGPL-3.0-or-later" +[lints] +workspace = true + [dependencies] tokio = { workspace = true } serde = { workspace = true } diff --git a/main/Cargo.toml b/main/Cargo.toml index 73b753b..e7b2301 100644 --- a/main/Cargo.toml +++ b/main/Cargo.toml @@ -5,6 +5,9 @@ edition = "2021" repository = "https://github.com/perstarkse/minne" license = "AGPL-3.0-or-later" +[lints] +workspace = true + [dependencies] tokio = { workspace = true } serde = { workspace = true }