diff --git a/Cargo.toml b/Cargo.toml index cb45c0afcb..a0f3f316fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ "crates/*", "plugins/*", ] -exclude = ["plugins/cli2", "plugins/db", "plugins/export", "crates/vad-ext"] +exclude = ["plugins/cli2", "plugins/db", "plugins/export", "plugins/extensions", "crates/vad-ext"] [workspace.dependencies] hypr-aec = { path = "crates/aec", package = "aec" } diff --git a/apps/api/src/main.rs b/apps/api/src/main.rs index 0f56a99d24..0981f99546 100644 --- a/apps/api/src/main.rs +++ b/apps/api/src/main.rs @@ -28,7 +28,7 @@ pub const DEVICE_FINGERPRINT_HEADER: &str = "x-device-fingerprint"; async fn app() -> Router { let env = env(); - let analytics = build_analytics_client(&env); + let analytics = build_analytics_client(env); let llm_config = hypr_llm_proxy::LlmProxyConfig::new(&env.llm).with_analytics(analytics.clone()); diff --git a/apps/cli/src/app.rs b/apps/cli/src/app.rs index c234a2addd..269e6ac95b 100644 --- a/apps/cli/src/app.rs +++ b/apps/cli/src/app.rs @@ -208,17 +208,9 @@ impl App { let cursor_row = memo_cursor_row.min(lines.len().saturating_sub(1)); let cursor_col = memo_cursor_col.min(current_line_len(lines, cursor_row)); - let row_start = if cursor_row + 1 > max_rows { - cursor_row + 1 - max_rows - } else { - 0 - }; + let row_start = (cursor_row + 1).saturating_sub(max_rows); - let col_start = if cursor_col + 1 > max_cols { - cursor_col + 1 - max_cols - } else { - 0 - }; + let col_start = (cursor_col + 1).saturating_sub(max_cols); let row_end = (row_start + max_rows).min(lines.len()); let lines = lines[row_start..row_end] @@ -407,9 +399,7 @@ impl App { return None; } - let Some(path) = normalize_pasted_path(&pasted) else { - return None; - }; + let path = normalize_pasted_path(&pasted)?; if !looks_like_audio_file(&path) { return None; diff --git a/apps/cli/src/audio_drop.rs b/apps/cli/src/audio_drop.rs index 864928ae25..33bdf80407 100644 --- a/apps/cli/src/audio_drop.rs +++ b/apps/cli/src/audio_drop.rs @@ -1,10 +1,10 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; pub struct AudioDropRequest { pub file_path: String, } -pub fn looks_like_audio_file(path: &PathBuf) -> bool { +pub fn looks_like_audio_file(path: &Path) -> bool { matches!( path.extension() .and_then(|ext| ext.to_str()) diff --git a/apps/cli/src/entry.rs b/apps/cli/src/entry.rs index d48453b087..6133b1ccc2 100644 --- a/apps/cli/src/entry.rs +++ b/apps/cli/src/entry.rs @@ -257,10 +257,10 @@ impl EntryApp { } if key.code == KeyCode::Enter { - if self.popup_visible { - if let Some(cmd) = self.selected_command_name() { - self.set_input_text(cmd.to_string()); - } + if self.popup_visible + && let Some(cmd) = self.selected_command_name() + { + self.set_input_text(cmd.to_string()); } let command = self.input_text().trim().to_string(); @@ -528,12 +528,12 @@ fn single_command_match_score(query: &str, command: &str) -> Option { return Some(1); } - if command.starts_with(&query) { + if command.starts_with(query) { let penalty = (command.len() as i32 - query.len() as i32).max(0); return Some(500 - penalty); } - if let Some(pos) = command.find(&query) { + if let Some(pos) = command.find(query) { return Some(350 - pos as i32); } diff --git a/crates/api-nango/src/extractor.rs b/crates/api-nango/src/extractor.rs index f5e4628d33..a27c1d190c 100644 --- a/crates/api-nango/src/extractor.rs +++ b/crates/api-nango/src/extractor.rs @@ -45,10 +45,10 @@ impl NangoConnectionState { integration_id: &str, ) -> Result { #[cfg(debug_assertions)] - if let Ok(connection_id) = std::env::var("DEV_NANGO_CONNECTION_ID") { - if !connection_id.is_empty() { - return Ok(connection_id); - } + if let Ok(connection_id) = std::env::var("DEV_NANGO_CONNECTION_ID") + && !connection_id.is_empty() + { + return Ok(connection_id); } let encoded_user_id = urlencoding::encode(user_id); diff --git a/crates/api-subscription/src/routes/billing.rs b/crates/api-subscription/src/routes/billing.rs index e232d72d67..d2ddd986da 100644 --- a/crates/api-subscription/src/routes/billing.rs +++ b/crates/api-subscription/src/routes/billing.rs @@ -109,10 +109,10 @@ where if let Err(e) = analytics.event(user_id, payload).await { tracing::warn!("analytics event error: {e}"); } - if let Some(props) = outcome.to_analytics_properties() { - if let Err(e) = analytics.set_properties(user_id, props).await { - tracing::warn!("analytics set_properties error: {e}"); - } + if let Some(props) = outcome.to_analytics_properties() + && let Err(e) = analytics.set_properties(user_id, props).await + { + tracing::warn!("analytics set_properties error: {e}"); } } outcome.into_response() diff --git a/crates/segmentation/src/onnx/mod.rs b/crates/segmentation/src/onnx/mod.rs index 832c803d87..f37552550e 100644 --- a/crates/segmentation/src/onnx/mod.rs +++ b/crates/segmentation/src/onnx/mod.rs @@ -208,7 +208,7 @@ impl Segmenter { } let has_last_chunk = num_samples < self.window_size - || (num_samples - self.window_size) % self.window_step_size > 0; + || !(num_samples - self.window_size).is_multiple_of(self.window_step_size); if has_last_chunk { starts.push(num_full_chunks * self.window_step_size); diff --git a/crates/tiptap/src/validate.rs b/crates/tiptap/src/validate.rs index ecffe1d634..405d4a42d2 100644 --- a/crates/tiptap/src/validate.rs +++ b/crates/tiptap/src/validate.rs @@ -70,13 +70,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { } for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if !is_block_type(ct) { - errors.push(ValidationError { - path: child_path.clone(), - message: format!("doc child must be a block node, got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && !is_block_type(ct) + { + errors.push(ValidationError { + path: child_path.clone(), + message: format!("doc child must be a block node, got '{ct}'"), + }); } validate_node(child, &child_path, errors); } @@ -85,13 +85,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { "paragraph" => { for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if !is_inline_type(ct) { - errors.push(ValidationError { - path: child_path.clone(), - message: format!("paragraph child must be an inline node, got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && !is_inline_type(ct) + { + errors.push(ValidationError { + path: child_path.clone(), + message: format!("paragraph child must be an inline node, got '{ct}'"), + }); } validate_node(child, &child_path, errors); } @@ -100,13 +100,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { "heading" => { for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if !is_inline_type(ct) { - errors.push(ValidationError { - path: child_path.clone(), - message: format!("heading child must be an inline node, got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && !is_inline_type(ct) + { + errors.push(ValidationError { + path: child_path.clone(), + message: format!("heading child must be an inline node, got '{ct}'"), + }); } validate_node(child, &child_path, errors); } @@ -122,13 +122,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { } for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if ct != "listItem" { - errors.push(ValidationError { - path: child_path.clone(), - message: format!("bulletList child must be 'listItem', got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && ct != "listItem" + { + errors.push(ValidationError { + path: child_path.clone(), + message: format!("bulletList child must be 'listItem', got '{ct}'"), + }); } validate_node(child, &child_path, errors); } @@ -145,13 +145,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { } for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if ct != "listItem" { - errors.push(ValidationError { - path: child_path.clone(), - message: format!("orderedList child must be 'listItem', got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && ct != "listItem" + { + errors.push(ValidationError { + path: child_path.clone(), + message: format!("orderedList child must be 'listItem', got '{ct}'"), + }); } validate_node(child, &child_path, errors); } @@ -167,13 +167,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { } for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if ct != "taskItem" { - errors.push(ValidationError { - path: child_path.clone(), - message: format!("taskList child must be 'taskItem', got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && ct != "taskItem" + { + errors.push(ValidationError { + path: child_path.clone(), + message: format!("taskList child must be 'taskItem', got '{ct}'"), + }); } validate_node(child, &child_path, errors); } @@ -200,13 +200,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { } for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if !is_block_type(ct) { - errors.push(ValidationError { - path: child_path.clone(), - message: format!("{typ} child must be a block node, got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && !is_block_type(ct) + { + errors.push(ValidationError { + path: child_path.clone(), + message: format!("{typ} child must be a block node, got '{ct}'"), + }); } validate_node(child, &child_path, errors); } @@ -223,13 +223,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { } for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if !is_block_type(ct) { - errors.push(ValidationError { - path: child_path.clone(), - message: format!("blockquote child must be a block node, got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && !is_block_type(ct) + { + errors.push(ValidationError { + path: child_path.clone(), + message: format!("blockquote child must be a block node, got '{ct}'"), + }); } validate_node(child, &child_path, errors); } @@ -238,13 +238,13 @@ fn validate_node(node: &Value, path: &str, errors: &mut Vec) { "codeBlock" => { for (i, child) in content.iter().enumerate() { let child_path = format!("{path}.content[{i}]"); - if let Some(ct) = node_type(child) { - if ct != "text" { - errors.push(ValidationError { - path: child_path, - message: format!("codeBlock child must be 'text', got '{ct}'"), - }); - } + if let Some(ct) = node_type(child) + && ct != "text" + { + errors.push(ValidationError { + path: child_path, + message: format!("codeBlock child must be 'text', got '{ct}'"), + }); } } } diff --git a/plugins/deeplink2/src/server/mod.rs b/plugins/deeplink2/src/server/mod.rs index 353cc229d6..66a9911020 100644 --- a/plugins/deeplink2/src/server/mod.rs +++ b/plugins/deeplink2/src/server/mod.rs @@ -33,8 +33,8 @@ pub struct CallbackServerState { active_port: Mutex>, } -impl CallbackServerState { - pub fn new() -> Self { +impl Default for CallbackServerState { + fn default() -> Self { Self { servers: Mutex::new(HashMap::new()), active_port: Mutex::new(None), @@ -42,6 +42,12 @@ impl CallbackServerState { } } +impl CallbackServerState { + pub fn new() -> Self { + Self::default() + } +} + pub fn render_html(deep_link: &DeepLink, scheme: &str) -> String { let (is_success, title, description) = ui_content(deep_link); render_template_html(scheme, is_success, title, description) @@ -196,10 +202,10 @@ async fn serve( if let Ok(mut servers) = state.servers.lock() { servers.remove(&port); } - if let Ok(mut active) = state.active_port.lock() { - if *active == Some(port) { - *active = None; - } + if let Ok(mut active) = state.active_port.lock() + && *active == Some(port) + { + *active = None; } } diff --git a/plugins/local-llm/src/ext.rs b/plugins/local-llm/src/ext.rs index 4378a21521..7a5c4736f3 100644 --- a/plugins/local-llm/src/ext.rs +++ b/plugins/local-llm/src/ext.rs @@ -32,7 +32,7 @@ impl ModelDownloaderRuntime for TauriModelRun }; let send_result = channel.send(progress); - let is_terminal = progress < 0 || progress >= 100; + let is_terminal = !(0..100).contains(&progress); if send_result.is_err() || is_terminal { guard.remove(&key); }