refactor(clippy): fix the never-loop error and clear all lint warnings
`cargo clippy --all-targets` was failing on a deny-by-default `never_loop` in the analysis SSE handler (the `loop` always returned on the first iteration — the stream `unfold` already re-enters per event), plus ~28 warnings. All resolved with no behaviour change: - admin/analysis SSE: drop the dead `loop` wrapper. - app: match port literals directly instead of `if p == 80` guards. - repo/user: separate doc list from the following paragraphs. - repo/upload_history: `sort_by_key(Reverse(..))` over `sort_by`. - crawler/nav test: construct the error directly (no `unwrap_err` on a literal `Err`). - test helpers: build configs via struct-update syntax instead of `Default::default()` + field reassignment; add a type alias for a complex audit-row tuple. - plus the mechanical `deref`/etc. fixes from `cargo clippy --fix`. Note: not running `cargo fmt` — the backend uses a consistent hand-formatted style that differs from rustfmt-default across ~110 files, so a blanket reformat would be pure churn. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1266,8 +1266,8 @@ fn parse_origin(raw: &str) -> Option<String> {
|
||||
let host = url.host_str()?;
|
||||
let scheme = url.scheme();
|
||||
let port_str = match (url.port(), scheme) {
|
||||
(Some(p), "http") if p == 80 => String::new(),
|
||||
(Some(p), "https") if p == 443 => String::new(),
|
||||
(Some(80), "http") => String::new(),
|
||||
(Some(443), "https") => String::new(),
|
||||
(Some(p), _) => format!(":{p}"),
|
||||
(None, _) => String::new(),
|
||||
};
|
||||
@@ -1509,7 +1509,6 @@ mod tests {
|
||||
let storage_dir = tempfile::tempdir().unwrap();
|
||||
let storage: Arc<dyn Storage> =
|
||||
Arc::new(LocalStorage::new(storage_dir.path()));
|
||||
let mut cfg = crate::config::AnalysisConfig::default();
|
||||
// The worker always runs OCR now (vision is dormant — see
|
||||
// `effective_backend`), and the `.rten` models aren't shipped to unit
|
||||
// CI. Point the engine at a path that can't exist so the *engine build*
|
||||
@@ -1518,10 +1517,13 @@ mod tests {
|
||||
// readiness, so the row must still be reclaimed even though spawn
|
||||
// returns Err. That's exactly the regression this test guards (an
|
||||
// analysis-only deploy must reclaim orphaned leases at startup).
|
||||
cfg.ocr_detection_model = "/nonexistent/text-detection.rten".to_string();
|
||||
cfg.ocr_recognition_model = "/nonexistent/text-recognition.rten".to_string();
|
||||
cfg.workers = 1;
|
||||
cfg.job_timeout = Duration::from_secs(1);
|
||||
let cfg = crate::config::AnalysisConfig {
|
||||
ocr_detection_model: "/nonexistent/text-detection.rten".to_string(),
|
||||
ocr_recognition_model: "/nonexistent/text-recognition.rten".to_string(),
|
||||
workers: 1,
|
||||
job_timeout: Duration::from_secs(1),
|
||||
..Default::default()
|
||||
};
|
||||
let events = Arc::new(crate::analysis::events::AnalysisEvents::new());
|
||||
|
||||
let spawned = spawn_analysis_daemon(pool.clone(), storage, &cfg, events).await;
|
||||
|
||||
Reference in New Issue
Block a user