diff --git a/src-tauri/src/audit/log.rs b/src-tauri/src/audit/log.rs index 7db8d241..45fb516c 100644 --- a/src-tauri/src/audit/log.rs +++ b/src-tauri/src/audit/log.rs @@ -97,9 +97,9 @@ mod tests { for i in 0..5 { write_audit_event( &conn, - &format!("action_{}", i), + &format!("action_{i}"), "test", - &format!("id_{}", i), + &format!("id_{i}"), "{}", ) .unwrap(); diff --git a/src-tauri/src/commands/integrations.rs b/src-tauri/src/commands/integrations.rs index 1240c7d7..d7e04c3b 100644 --- a/src-tauri/src/commands/integrations.rs +++ b/src-tauri/src/commands/integrations.rs @@ -94,7 +94,7 @@ pub async fn initiate_oauth( let (mut callback_rx, shutdown_tx) = crate::integrations::callback_server::start_callback_server(8765) .await - .map_err(|e| format!("Failed to start callback server: {}", e))?; + .map_err(|e| format!("Failed to start callback server: {e}"))?; // Store shutdown channel { @@ -123,7 +123,7 @@ pub async fn initiate_oauth( let mut oauth_state = match OAUTH_STATE.lock() { Ok(state) => state, Err(e) => { - tracing::error!("Failed to lock OAuth state: {}", e); + tracing::error!("Failed to lock OAuth state: {e}"); continue; } }; @@ -148,7 +148,7 @@ pub async fn initiate_oauth( match result { Ok(_) => tracing::info!("OAuth callback handled successfully"), - Err(e) => tracing::error!("OAuth callback failed: {}", e), + Err(e) => tracing::error!("OAuth callback failed: {e}"), } } @@ -166,7 +166,7 @@ pub async fn initiate_oauth( { let mut oauth_state = OAUTH_STATE .lock() - .map_err(|e| format!("Failed to lock OAuth state: {}", e))?; + .map_err(|e| format!("Failed to lock OAuth state: {e}"))?; oauth_state.insert( state_key.clone(), (service.clone(), pkce.code_verifier.clone()), @@ -193,7 +193,7 @@ pub async fn initiate_oauth( // ServiceNow uses basic auth, not OAuth2 return Err("ServiceNow uses basic authentication, not OAuth2".to_string()); } - _ => return Err(format!("Unknown service: {}", service)), + _ => return Err(format!("Unknown service: {service}")), }; let auth_url = crate::integrations::auth::build_auth_url( @@ -231,7 +231,7 @@ async fn handle_oauth_callback_internal( .unwrap_or_else(|_| "ado-client-id-placeholder".to_string()), "http://localhost:8765/callback", ), - _ => return Err(format!("Unknown service: {}", service)), + _ => return Err(format!("Unknown service: {service}")), }; // Exchange authorization code for access token @@ -265,7 +265,7 @@ async fn handle_oauth_callback_internal( let db = app_state .db .lock() - .map_err(|e| format!("Failed to lock database: {}", e))?; + .map_err(|e| format!("Failed to lock database: {e}"))?; db.execute( "INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at) @@ -279,7 +279,7 @@ async fn handle_oauth_callback_internal( expires_at, ], ) - .map_err(|e| format!("Failed to store credentials: {}", e))?; + .map_err(|e| format!("Failed to store credentials: {e}"))?; // Log audit event let audit_details = serde_json::json!({ @@ -301,7 +301,7 @@ async fn handle_oauth_callback_internal( audit_details.to_string(), ], ) - .map_err(|e| format!("Failed to log audit event: {}", e))?; + .map_err(|e| format!("Failed to log audit event: {e}"))?; Ok(()) } @@ -319,7 +319,7 @@ pub async fn handle_oauth_callback( let verifier = { let mut oauth_state = OAUTH_STATE .lock() - .map_err(|e| format!("Failed to lock OAuth state: {}", e))?; + .map_err(|e| format!("Failed to lock OAuth state: {e}"))?; oauth_state .remove(&state_key) .map(|(_svc, ver)| ver) @@ -520,7 +520,7 @@ pub async fn authenticate_with_webview( if let Some(existing_label) = app_state .integration_webviews .lock() - .map_err(|e| format!("Failed to lock webviews: {}", e))? + .map_err(|e| format!("Failed to lock webviews: {e}"))? .get(&service) { if app_handle.get_webview_window(existing_label).is_some() { @@ -545,7 +545,7 @@ pub async fn authenticate_with_webview( app_state .integration_webviews .lock() - .map_err(|e| format!("Failed to lock webviews: {}", e))? + .map_err(|e| format!("Failed to lock webviews: {e}"))? .insert(service.clone(), webview_id.clone()); Ok(WebviewAuthResponse { @@ -582,8 +582,8 @@ pub async fn extract_cookies_from_webview( } // Encrypt and store cookies in database - let cookies_json = serde_json::to_string(&cookies) - .map_err(|e| format!("Failed to serialize cookies: {}", e))?; + let cookies_json = + serde_json::to_string(&cookies).map_err(|e| format!("Failed to serialize cookies: {e}"))?; let encrypted_cookies = crate::integrations::auth::encrypt_token(&cookies_json)?; let token_hash = { @@ -597,7 +597,7 @@ pub async fn extract_cookies_from_webview( let db = app_state .db .lock() - .map_err(|e| format!("Failed to lock database: {}", e))?; + .map_err(|e| format!("Failed to lock database: {e}"))?; db.execute( "INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at) @@ -611,13 +611,13 @@ pub async fn extract_cookies_from_webview( None::, // Cookies don't have explicit expiry ], ) - .map_err(|e| format!("Failed to store cookies: {}", e))?; + .map_err(|e| format!("Failed to store cookies: {e}"))?; // Close the webview window if let Some(webview) = app_handle.get_webview_window(&webview_id) { webview .close() - .map_err(|e| format!("Failed to close webview: {}", e))?; + .map_err(|e| format!("Failed to close webview: {e}"))?; } Ok(ConnectionResult { @@ -698,7 +698,7 @@ pub async fn save_manual_token( let db = app_state .db .lock() - .map_err(|e| format!("Failed to lock database: {}", e))?; + .map_err(|e| format!("Failed to lock database: {e}"))?; db.execute( "INSERT OR REPLACE INTO credentials (id, service, token_hash, encrypted_token, created_at, expires_at) @@ -712,7 +712,7 @@ pub async fn save_manual_token( None::, ], ) - .map_err(|e| format!("Failed to store token: {}", e))?; + .map_err(|e| format!("Failed to store token: {e}"))?; // Log audit event db.execute( @@ -732,7 +732,7 @@ pub async fn save_manual_token( .to_string(), ], ) - .map_err(|e| format!("Failed to log audit event: {}", e))?; + .map_err(|e| format!("Failed to log audit event: {e}"))?; Ok(ConnectionResult { success: true, @@ -757,7 +757,7 @@ pub async fn get_fresh_cookies_from_webview( let webviews = app_state .integration_webviews .lock() - .map_err(|e| format!("Failed to lock webviews: {}", e))?; + .map_err(|e| format!("Failed to lock webviews: {e}"))?; match webviews.get(service) { Some(label) => label.clone(), @@ -773,7 +773,7 @@ pub async fn get_fresh_cookies_from_webview( app_state .integration_webviews .lock() - .map_err(|e| format!("Failed to lock webviews: {}", e))? + .map_err(|e| format!("Failed to lock webviews: {e}"))? .remove(service); return Ok(None); } @@ -814,7 +814,7 @@ pub async fn save_integration_config( let db = app_state .db .lock() - .map_err(|e| format!("Failed to lock database: {}", e))?; + .map_err(|e| format!("Failed to lock database: {e}"))?; db.execute( "INSERT OR REPLACE INTO integration_config @@ -829,7 +829,7 @@ pub async fn save_integration_config( config.space_key, ], ) - .map_err(|e| format!("Failed to save integration config: {}", e))?; + .map_err(|e| format!("Failed to save integration config: {e}"))?; Ok(()) } @@ -843,11 +843,11 @@ pub async fn get_integration_config( let db = app_state .db .lock() - .map_err(|e| format!("Failed to lock database: {}", e))?; + .map_err(|e| format!("Failed to lock database: {e}"))?; let mut stmt = db .prepare("SELECT service, base_url, username, project_name, space_key FROM integration_config WHERE service = ?1") - .map_err(|e| format!("Failed to prepare query: {}", e))?; + .map_err(|e| format!("Failed to prepare query: {e}"))?; let config = stmt .query_row([&service], |row| { @@ -860,7 +860,7 @@ pub async fn get_integration_config( }) }) .optional() - .map_err(|e| format!("Failed to query integration config: {}", e))?; + .map_err(|e| format!("Failed to query integration config: {e}"))?; Ok(config) } @@ -873,13 +873,13 @@ pub async fn get_all_integration_configs( let db = app_state .db .lock() - .map_err(|e| format!("Failed to lock database: {}", e))?; + .map_err(|e| format!("Failed to lock database: {e}"))?; let mut stmt = db .prepare( "SELECT service, base_url, username, project_name, space_key FROM integration_config", ) - .map_err(|e| format!("Failed to prepare query: {}", e))?; + .map_err(|e| format!("Failed to prepare query: {e}"))?; let configs = stmt .query_map([], |row| { @@ -891,9 +891,9 @@ pub async fn get_all_integration_configs( space_key: row.get(4)?, }) }) - .map_err(|e| format!("Failed to query integration configs: {}", e))? + .map_err(|e| format!("Failed to query integration configs: {e}"))? .collect::, _>>() - .map_err(|e| format!("Failed to collect integration configs: {}", e))?; + .map_err(|e| format!("Failed to collect integration configs: {e}"))?; Ok(configs) } diff --git a/src-tauri/src/db/migrations.rs b/src-tauri/src/db/migrations.rs index e860aaef..865aebae 100644 --- a/src-tauri/src/db/migrations.rs +++ b/src-tauri/src/db/migrations.rs @@ -162,13 +162,13 @@ pub fn run_migrations(conn: &Connection) -> anyhow::Result<()> { // FTS5 virtual table creation can be skipped if FTS5 is not compiled in if let Err(e) = conn.execute_batch(sql) { if name.contains("fts") { - tracing::warn!("FTS5 not available, skipping: {}", e); + tracing::warn!("FTS5 not available, skipping: {e}"); } else { return Err(e.into()); } } conn.execute("INSERT INTO _migrations (name) VALUES (?1)", [name])?; - tracing::info!("Applied migration: {}", name); + tracing::info!("Applied migration: {name}"); } } diff --git a/src-tauri/src/integrations/auth.rs b/src-tauri/src/integrations/auth.rs index fc9d1dba..506e209a 100644 --- a/src-tauri/src/integrations/auth.rs +++ b/src-tauri/src/integrations/auth.rs @@ -88,7 +88,7 @@ pub async fn exchange_code( .form(¶ms) .send() .await - .map_err(|e| format!("Failed to send token exchange request: {}", e))?; + .map_err(|e| format!("Failed to send token exchange request: {e}"))?; if !resp.status().is_success() { return Err(format!( @@ -101,7 +101,7 @@ pub async fn exchange_code( let body: serde_json::Value = resp .json() .await - .map_err(|e| format!("Failed to parse token response: {}", e))?; + .map_err(|e| format!("Failed to parse token response: {e}"))?; let access_token = body["access_token"] .as_str() @@ -208,7 +208,7 @@ pub fn encrypt_token(token: &str) -> Result { // Encrypt let ciphertext = cipher .encrypt(nonce, token.as_bytes()) - .map_err(|e| format!("Encryption failed: {}", e))?; + .map_err(|e| format!("Encryption failed: {e}"))?; // Prepend nonce to ciphertext let mut result = nonce_bytes.to_vec(); @@ -232,7 +232,7 @@ pub fn decrypt_token(encrypted: &str) -> Result { use base64::Engine; let data = STANDARD .decode(encrypted) - .map_err(|e| format!("Base64 decode failed: {}", e))?; + .map_err(|e| format!("Base64 decode failed: {e}"))?; if data.len() < 12 { return Err("Invalid encrypted data: too short".to_string()); @@ -256,9 +256,9 @@ pub fn decrypt_token(encrypted: &str) -> Result { // Decrypt let plaintext = cipher .decrypt(nonce, ciphertext) - .map_err(|e| format!("Decryption failed: {}", e))?; + .map_err(|e| format!("Decryption failed: {e}"))?; - String::from_utf8(plaintext).map_err(|e| format!("Invalid UTF-8: {}", e)) + String::from_utf8(plaintext).map_err(|e| format!("Invalid UTF-8: {e}")) } #[cfg(test)] diff --git a/src-tauri/src/integrations/azuredevops.rs b/src-tauri/src/integrations/azuredevops.rs index a8651516..e05e6ab7 100644 --- a/src-tauri/src/integrations/azuredevops.rs +++ b/src-tauri/src/integrations/azuredevops.rs @@ -32,7 +32,7 @@ pub async fn test_connection(config: &AzureDevOpsConfig) -> Result Result Result, String .query(&[("limit", "100")]) .send() .await - .map_err(|e| format!("Failed to list spaces: {}", e))?; + .map_err(|e| format!("Failed to list spaces: {e}"))?; if !resp.status().is_success() { return Err(format!( @@ -74,7 +74,7 @@ pub async fn list_spaces(config: &ConfluenceConfig) -> Result, String let body: serde_json::Value = resp .json() .await - .map_err(|e| format!("Failed to parse response: {}", e))?; + .map_err(|e| format!("Failed to parse response: {e}"))?; let spaces = body["results"] .as_array() @@ -114,7 +114,7 @@ pub async fn search_pages( .query(&[("cql", &cql), ("limit", &"50".to_string())]) .send() .await - .map_err(|e| format!("Search failed: {}", e))?; + .map_err(|e| format!("Search failed: {e}"))?; if !resp.status().is_success() { return Err(format!( @@ -127,7 +127,7 @@ pub async fn search_pages( let body: serde_json::Value = resp .json() .await - .map_err(|e| format!("Failed to parse response: {}", e))?; + .map_err(|e| format!("Failed to parse response: {e}"))?; let pages = body["results"] .as_array() @@ -182,7 +182,7 @@ pub async fn publish_page( .json(&body) .send() .await - .map_err(|e| format!("Failed to publish page: {}", e))?; + .map_err(|e| format!("Failed to publish page: {e}"))?; if !resp.status().is_success() { return Err(format!( @@ -195,7 +195,7 @@ pub async fn publish_page( let result: serde_json::Value = resp .json() .await - .map_err(|e| format!("Failed to parse response: {}", e))?; + .map_err(|e| format!("Failed to parse response: {e}"))?; let page_id = result["id"].as_str().unwrap_or(""); let page_url = format!( @@ -245,7 +245,7 @@ pub async fn update_page( .json(&body) .send() .await - .map_err(|e| format!("Failed to update page: {}", e))?; + .map_err(|e| format!("Failed to update page: {e}"))?; if !resp.status().is_success() { return Err(format!( @@ -258,7 +258,7 @@ pub async fn update_page( let result: serde_json::Value = resp .json() .await - .map_err(|e| format!("Failed to parse response: {}", e))?; + .map_err(|e| format!("Failed to parse response: {e}"))?; let updated_page_id = result["id"].as_str().unwrap_or(page_id); let page_url = format!( diff --git a/src-tauri/src/integrations/servicenow.rs b/src-tauri/src/integrations/servicenow.rs index b54d8254..9e0bd072 100644 --- a/src-tauri/src/integrations/servicenow.rs +++ b/src-tauri/src/integrations/servicenow.rs @@ -34,7 +34,7 @@ pub async fn test_connection(config: &ServiceNowConfig) -> Result format!("{}/login.do", base_url.trim_end_matches('/')), - _ => return Err(format!("Unknown service: {}", service)), + _ => return Err(format!("Unknown service: {service}")), }; tracing::info!( @@ -46,11 +46,7 @@ pub async fn authenticate_with_webview( let webview = WebviewWindowBuilder::new( &app_handle, &webview_label, - WebviewUrl::External( - login_url - .parse() - .map_err(|e| format!("Invalid URL: {}", e))?, - ), + WebviewUrl::External(login_url.parse().map_err(|e| format!("Invalid URL: {e}"))?), ) .title(format!("{} Browser (TFTSR)", service)) .inner_size(1000.0, 800.0) @@ -60,12 +56,12 @@ pub async fn authenticate_with_webview( .focused(true) .visible(true) .build() - .map_err(|e| format!("Failed to create webview: {}", e))?; + .map_err(|e| format!("Failed to create webview: {e}"))?; // Focus the window webview .set_focus() - .map_err(|e| tracing::warn!("Failed to focus webview: {}", e)) + .map_err(|e| tracing::warn!("Failed to focus webview: {e}")) .ok(); // Wait for user to complete login @@ -147,7 +143,7 @@ pub async fn extract_cookies_via_ipc( match serde_json::from_str::(payload_str) { Ok(payload) => { if let Some(error_msg) = payload.get("error").and_then(|e| e.as_str()) { - let _ = tx.try_send(Err(format!("JavaScript error: {}", error_msg))); + let _ = tx.try_send(Err(format!("JavaScript error: {error_msg}"))); return; } @@ -158,8 +154,8 @@ pub async fn extract_cookies_via_ipc( let _ = tx.try_send(Ok(cookies)); } Err(e) => { - tracing::error!("Failed to parse cookies: {}", e); - let _ = tx.try_send(Err(format!("Failed to parse cookies: {}", e))); + tracing::error!("Failed to parse cookies: {e}"); + let _ = tx.try_send(Err(format!("Failed to parse cookies: {e}"))); } } } else { @@ -167,8 +163,8 @@ pub async fn extract_cookies_via_ipc( } } Err(e) => { - tracing::error!("Failed to parse event payload: {}", e); - let _ = tx.try_send(Err(format!("Failed to parse event payload: {}", e))); + tracing::error!("Failed to parse event payload: {e}"); + let _ = tx.try_send(Err(format!("Failed to parse event payload: {e}"))); } } }); @@ -176,7 +172,7 @@ pub async fn extract_cookies_via_ipc( // Inject the script into the webview webview_window .eval(cookie_extraction_script) - .map_err(|e| format!("Failed to inject cookie extraction script: {}", e))?; + .map_err(|e| format!("Failed to inject cookie extraction script: {e}"))?; tracing::info!("Cookie extraction script injected, waiting for response...");