fix: resolve all clippy warnings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
master
oabrivard 3 months ago
parent fa9375233e
commit 7cd867c650

@ -21,6 +21,7 @@ pub struct LlmCallLogRow {
} }
/// Insert a single LLM call log entry. /// Insert a single LLM call log entry.
#[allow(clippy::too_many_arguments)]
pub async fn insert( pub async fn insert(
pool: &PgPool, pool: &PgPool,
user_id: Uuid, user_id: Uuid,

@ -60,6 +60,7 @@ const GENERIC_AUTH_MESSAGE: &str =
/// Validates the Turnstile token, checks if the user already exists: /// Validates the Turnstile token, checks if the user already exists:
/// - If the user exists, sends a magic link (same as login). /// - If the user exists, sends a magic link (same as login).
/// - If not, creates the user and sends a magic link. /// - If not, creates the user and sends a magic link.
///
/// Always returns the same response to prevent email enumeration. /// Always returns the same response to prevent email enumeration.
pub async fn register( pub async fn register(
State(state): State<AppState>, State(state): State<AppState>,

@ -169,10 +169,10 @@ fn strip_code_fences(text: &str) -> &str {
let trimmed = text.trim(); let trimmed = text.trim();
// Check for ```json or ``` prefix // Check for ```json or ``` prefix
let without_prefix = if trimmed.starts_with("```json") { let without_prefix = if let Some(stripped) = trimmed.strip_prefix("```json") {
&trimmed[7..] stripped
} else if trimmed.starts_with("```") { } else if let Some(stripped) = trimmed.strip_prefix("```") {
&trimmed[3..] stripped
} else { } else {
return trimmed; return trimmed;
}; };

@ -146,6 +146,12 @@ struct ProviderRateLimiterInner {
const DEFAULT_MAX_REQUESTS: u32 = 29; const DEFAULT_MAX_REQUESTS: u32 = 29;
const DEFAULT_TIME_WINDOW_SECS: u64 = 60; const DEFAULT_TIME_WINDOW_SECS: u64 = 60;
impl Default for ProviderRateLimiter {
fn default() -> Self {
Self::new()
}
}
impl ProviderRateLimiter { impl ProviderRateLimiter {
/// Create a new provider rate limiter with empty buckets. /// Create a new provider rate limiter with empty buckets.
/// ///

@ -449,11 +449,7 @@ fn detect_short_page_error(body_text: &str) -> bool {
for (idx, _) in lower.match_indices("404") { for (idx, _) in lower.match_indices("404") {
for kw in &proximity_keywords { for kw in &proximity_keywords {
if let Some(kw_idx) = lower.find(kw) { if let Some(kw_idx) = lower.find(kw) {
let distance = if idx > kw_idx { let distance = idx.abs_diff(kw_idx);
idx - kw_idx
} else {
kw_idx - idx
};
if distance <= 50 { if distance <= 50 {
return true; return true;
} }

@ -126,6 +126,7 @@ pub fn extract_body_html(html: &str) -> String {
/// Extract article links using LLM analysis of the page HTML. /// Extract article links using LLM analysis of the page HTML.
/// ///
/// Falls back to heuristic extraction if the LLM call fails or returns empty. /// Falls back to heuristic extraction if the LLM call fails or returns empty.
#[allow(clippy::too_many_arguments)]
pub async fn extract_article_links_with_llm( pub async fn extract_article_links_with_llm(
http_client: &reqwest::Client, http_client: &reqwest::Client,
source_url: &str, source_url: &str,

@ -87,6 +87,12 @@ pub struct JobStore {
/// Jobs expire after 1 hour (allows SSE reconnection). /// Jobs expire after 1 hour (allows SSE reconnection).
const JOB_TTL: Duration = Duration::from_secs(3600); const JOB_TTL: Duration = Duration::from_secs(3600);
impl Default for JobStore {
fn default() -> Self {
Self::new()
}
}
impl JobStore { impl JobStore {
/// Create a new empty job store. /// Create a new empty job store.
pub fn new() -> Self { pub fn new() -> Self {
@ -593,7 +599,7 @@ async fn run_generation_inner(
// History dedup // History dedup
if settings.article_history_days > 0 { if settings.article_history_days > 0 {
let hash = hash_article_url(&item.url); let hash = hash_article_url(&item.url);
let exists = db::article_history::check_urls_exist(&state.pool, user_id, &[hash.clone()]).await.unwrap_or_default(); let exists = db::article_history::check_urls_exist(&state.pool, user_id, std::slice::from_ref(&hash)).await.unwrap_or_default();
if exists.contains(&hash) { if exists.contains(&hash) {
trace_article(&state.pool, user_id, job_id, &item.url, &item.title, "web_search", None, None, None, "filtered_history", false).await; trace_article(&state.pool, user_id, job_id, &item.url, &item.title, "web_search", None, None, None, "filtered_history", false).await;
continue; continue;
@ -711,6 +717,7 @@ fn emit_progress(tx: &watch::Sender<ProgressEvent>, step: &str, message: &str, p
} }
/// Insert a trace entry into article_history for debugging pipeline behavior. /// Insert a trace entry into article_history for debugging pipeline behavior.
#[allow(clippy::too_many_arguments)]
async fn trace_article( async fn trace_article(
pool: &sqlx::PgPool, pool: &sqlx::PgPool,
user_id: Uuid, user_id: Uuid,
@ -741,6 +748,7 @@ async fn trace_article(
} }
/// Log an LLM call with full prompt, response, and timing. /// Log an LLM call with full prompt, response, and timing.
#[allow(clippy::too_many_arguments)]
async fn log_llm_call( async fn log_llm_call(
pool: &sqlx::PgPool, pool: &sqlx::PgPool,
user_id: Uuid, user_id: Uuid,
@ -1024,14 +1032,8 @@ fn rotate_sources(sources: Vec<crate::models::source::Source>, last_source_url:
} }
} }
/// Scrape a single article URL, returning (body_text, page_title, final_url) or empty strings on failure. /// Scrape a single article. Returns (body_text, page_title, final_url, drop_reason).
/// /// `drop_reason` is `Some("filtered_empty")` or `Some("filtered_too_old")` if rejected, `None` if OK.
/// Handles all failure modes gracefully:
/// - Network errors → empty content (article kept)
/// - Soft 404 → article excluded (empty content)
/// - Article too old → article excluded (empty content)
/// Result of scraping a single article.
/// The 4th value is the drop reason if the article was rejected (None if OK).
async fn scrape_single_article( async fn scrape_single_article(
http_client: &reqwest::Client, http_client: &reqwest::Client,
url: &str, url: &str,

Loading…
Cancel
Save