diff --git a/src/fixtures/data/mod.rs b/src/fixtures/data/mod.rs index ccc31ae..a0d3ddd 100644 --- a/src/fixtures/data/mod.rs +++ b/src/fixtures/data/mod.rs @@ -220,30 +220,30 @@ pub fn openai_embedding_response(dimensions: usize) -> Value { } #[must_use] -pub fn sample_kb_entries() -> Vec { +pub fn sample_kb_entries() -> Vec { vec![ - KBEntry { + KbEntry { id: "kb-001".to_string(), title: "Product Overview".to_string(), content: "Our product is a comprehensive solution for business automation.".to_string(), category: Some("products".to_string()), tags: vec!["product".to_string(), "overview".to_string()], }, - KBEntry { + KbEntry { id: "kb-002".to_string(), title: "Pricing Plans".to_string(), content: "We offer three pricing plans: Basic ($29/mo), Pro ($79/mo), and Enterprise (custom).".to_string(), category: Some("pricing".to_string()), tags: vec!["pricing".to_string(), "plans".to_string()], }, - KBEntry { + KbEntry { id: "kb-003".to_string(), title: "Support Hours".to_string(), content: "Our support team is available 24/7 for Enterprise customers and 9-5 EST for other plans.".to_string(), category: Some("support".to_string()), tags: vec!["support".to_string(), "hours".to_string()], }, - KBEntry { + KbEntry { id: "kb-004".to_string(), title: "Return Policy".to_string(), content: "We offer a 30-day money-back guarantee on all plans. No questions asked.".to_string(), @@ -254,7 +254,7 @@ pub fn sample_kb_entries() -> Vec { } #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct KBEntry { +pub struct KbEntry { pub id: String, pub title: String, pub content: String, @@ -303,27 +303,27 @@ pub struct Product { } #[must_use] -pub fn sample_faqs() -> Vec { +pub fn sample_faqs() -> Vec { vec![ - FAQ { + Faq { id: 1, question: "How do I reset my password?".to_string(), answer: "You can reset your password by clicking 'Forgot Password' on the login page.".to_string(), category: "account".to_string(), }, - FAQ { + Faq { id: 2, question: "What payment methods do you accept?".to_string(), answer: "We accept all major credit cards, PayPal, and bank transfers.".to_string(), category: "billing".to_string(), }, - FAQ { + Faq { id: 3, question: "How do I contact support?".to_string(), answer: "You can reach our support team via email at support@example.com or through live chat.".to_string(), category: "support".to_string(), }, - FAQ { + Faq { id: 4, question: "Can I cancel my subscription?".to_string(), answer: "Yes, you can cancel your subscription at any time from your account settings.".to_string(), @@ -333,8 +333,7 @@ pub fn sample_faqs() -> Vec { } #[derive(Debug, Clone, Serialize, Deserialize)] -#[allow(clippy::upper_case_acronyms)] -pub struct FAQ { +pub struct Faq { pub id: u32, pub question: String, pub answer: String, diff --git a/src/fixtures/mod.rs b/src/fixtures/mod.rs index 5abd796..aba1aae 100644 --- a/src/fixtures/mod.rs +++ b/src/fixtures/mod.rs @@ -74,16 +74,15 @@ impl Default for Customer { #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] -#[allow(clippy::upper_case_acronyms)] #[derive(Default)] pub enum Channel { #[default] WhatsApp, Teams, Web, - SMS, + Sms, Email, - API, + Api, } diff --git a/src/mocks/llm.rs b/src/mocks/llm.rs index 3cec005..321a495 100644 --- a/src/mocks/llm.rs +++ b/src/mocks/llm.rs @@ -90,11 +90,13 @@ struct ChatChoice { } #[derive(Serialize)] -#[allow(clippy::struct_field_names)] struct Usage { - prompt_tokens: u32, - completion_tokens: u32, - total_tokens: u32, + #[serde(rename = "prompt_tokens")] + pub prompt: u32, + #[serde(rename = "completion_tokens")] + pub completion: u32, + #[serde(rename = "total_tokens")] + pub total: u32, } #[derive(Debug, Deserialize)] @@ -127,8 +129,10 @@ struct EmbeddingData { #[derive(Serialize)] struct EmbeddingUsage { - prompt_tokens: u32, - total_tokens: u32, + #[serde(rename = "prompt_tokens")] + pub prompt: u32, + #[serde(rename = "total_tokens")] + pub total: u32, } #[derive(Serialize)] @@ -249,9 +253,9 @@ impl MockLLM { finish_reason: "stop".to_string(), }], usage: Usage { - prompt_tokens: 10, - completion_tokens: 20, - total_tokens: 30, + prompt: 10, + completion: 20, + total: 30, }, }; @@ -399,9 +403,9 @@ impl MockLLM { finish_reason: "tool_calls".to_string(), }], usage: Usage { - prompt_tokens: 10, - completion_tokens: 20, - total_tokens: 30, + prompt: 10, + completion: 20, + total: 30, }, }; @@ -426,8 +430,8 @@ impl MockLLM { }], model: "text-embedding-ada-002".to_string(), usage: EmbeddingUsage { - prompt_tokens: 5, - total_tokens: 5, + prompt: 5, + total: 5, }, }; @@ -448,8 +452,8 @@ impl MockLLM { }], model: "text-embedding-ada-002".to_string(), usage: EmbeddingUsage { - prompt_tokens: 5, - total_tokens: 5, + prompt: 5, + total: 5, }, }; @@ -558,9 +562,9 @@ impl MockLLM { finish_reason: "stop".to_string(), }], usage: Usage { - prompt_tokens: 10, - completion_tokens: 20, - total_tokens: 30, + prompt: 10, + completion: 20, + total: 30, }, }; @@ -666,9 +670,9 @@ mod tests { finish_reason: "stop".to_string(), }], usage: Usage { - prompt_tokens: 10, - completion_tokens: 5, - total_tokens: 15, + prompt: 10, + completion: 5, + total: 15, }, }; diff --git a/src/mocks/teams.rs b/src/mocks/teams.rs index 8613a3c..5c77fdc 100644 --- a/src/mocks/teams.rs +++ b/src/mocks/teams.rs @@ -21,10 +21,9 @@ pub struct MockTeams { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -#[allow(clippy::struct_field_names)] pub struct Activity { #[serde(rename = "type")] - pub activity_type: String, + pub kind: String, pub id: String, pub timestamp: String, #[serde(skip_serializing_if = "Option::is_none")] @@ -59,7 +58,7 @@ pub struct Activity { impl Default for Activity { fn default() -> Self { Self { - activity_type: "message".to_string(), + kind: "message".to_string(), id: Uuid::new_v4().to_string(), timestamp: chrono::Utc::now().to_rfc3339(), local_timestamp: None, @@ -124,10 +123,9 @@ pub struct Attachment { #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -#[allow(clippy::struct_field_names)] pub struct Entity { #[serde(rename = "type")] - pub entity_type: String, + pub kind: String, #[serde(skip_serializing_if = "Option::is_none")] pub mentioned: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -292,7 +290,7 @@ impl MockTeams { let body: serde_json::Value = req.body_json().unwrap_or_default(); let activity = Activity { - activity_type: body + kind: body .get("type") .and_then(|v| v.as_str()) .unwrap_or("message") @@ -433,7 +431,7 @@ impl MockTeams { let conversation_id = format!("conv-{}", Uuid::new_v4()); Activity { - activity_type: "message".to_string(), + kind: "message".to_string(), id: Uuid::new_v4().to_string(), timestamp: chrono::Utc::now().to_rfc3339(), local_timestamp: Some(chrono::Utc::now().to_rfc3339()), @@ -483,7 +481,7 @@ impl MockTeams { activity.text = Some(format!("{mention_text} {text}")); activity.entities = Some(vec![Entity { - entity_type: "mention".to_string(), + kind: "mention".to_string(), mentioned: Some(ChannelAccount { id: self.bot_id.clone(), name: Some(self.bot_name.clone()), @@ -502,7 +500,7 @@ impl MockTeams { let conversation_id = format!("conv-{}", Uuid::new_v4()); Activity { - activity_type: "conversationUpdate".to_string(), + kind: "conversationUpdate".to_string(), id: Uuid::new_v4().to_string(), timestamp: chrono::Utc::now().to_rfc3339(), local_timestamp: None, @@ -556,7 +554,7 @@ impl MockTeams { let conversation_id = format!("conv-{}", Uuid::new_v4()); Activity { - activity_type: "invoke".to_string(), + kind: "invoke".to_string(), id: Uuid::new_v4().to_string(), timestamp: chrono::Utc::now().to_rfc3339(), local_timestamp: None, @@ -630,7 +628,7 @@ impl MockTeams { let conversation_id = format!("conv-{}", Uuid::new_v4()); Activity { - activity_type: "messageReaction".to_string(), + kind: "messageReaction".to_string(), id: Uuid::new_v4().to_string(), timestamp: chrono::Utc::now().to_rfc3339(), local_timestamp: None, @@ -831,7 +829,7 @@ mod tests { #[test] fn test_activity_default() { let activity = Activity::default(); - assert_eq!(activity.activity_type, "message"); + assert_eq!(activity.kind, "message"); assert_eq!(activity.channel_id, "msteams"); assert!(!activity.id.is_empty()); } @@ -839,7 +837,7 @@ mod tests { #[test] fn test_activity_serialization() { let activity = Activity { - activity_type: "message".to_string(), + kind: "message".to_string(), id: "test-id".to_string(), timestamp: "2024-01-01T00:00:00Z".to_string(), local_timestamp: None, @@ -910,7 +908,7 @@ mod tests { #[test] fn test_entity_mention() { let entity = Entity { - entity_type: "mention".to_string(), + kind: "mention".to_string(), mentioned: Some(ChannelAccount { id: "bot-id".to_string(), name: Some("Bot".to_string()), diff --git a/src/services/browser_service.rs b/src/services/browser_service.rs index e732913..8a15912 100644 --- a/src/services/browser_service.rs +++ b/src/services/browser_service.rs @@ -168,8 +168,8 @@ impl BrowserService { self.port } - #[allow(clippy::unused_async)] pub async fn stop(&mut self) -> Result<()> { + tokio::task::yield_now().await; if let Some(mut process) = self.process.take() { info!("Stopping browser"); process.kill().ok(); diff --git a/src/services/redis.rs b/src/services/redis.rs index dd9780c..6211dd2 100644 --- a/src/services/redis.rs +++ b/src/services/redis.rs @@ -49,8 +49,8 @@ impl RedisService { Ok(service) } - #[allow(clippy::unused_async)] async fn start_server(&mut self) -> Result<()> { + tokio::task::yield_now().await; log::info!("Starting Redis on port {}", self.port); let redis = Self::find_binary()?; @@ -125,8 +125,8 @@ impl RedisService { Ok(()) } - #[allow(clippy::unused_async)] pub async fn execute(&self, args: &[&str]) -> Result { + tokio::task::yield_now().await; let redis_cli = Self::find_cli_binary()?; let mut cmd = Command::new(&redis_cli); diff --git a/src/web/mod.rs b/src/web/mod.rs index f9d8a45..0569738 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -107,10 +107,9 @@ impl Locator { } #[must_use] - #[allow(clippy::match_same_arms)] pub fn to_css_selector(&self) -> String { match self { - Self::Css(s) => s.clone(), + Self::Css(s) | Self::TagName(s) => s.clone(), Self::XPath(_) => { log::warn!("XPath locators not directly supported in CDP, use CSS selectors"); "*".to_string() @@ -119,7 +118,6 @@ impl Locator { Self::Name(s) => format!("[name='{s}']"), Self::LinkText(s) => format!("a:contains('{s}')"), Self::PartialLinkText(s) => format!("a[href*='{s}']"), - Self::TagName(s) => s.clone(), Self::ClassName(s) => format!(".{s}"), } }