style: Apply cargo fmt and clippy fixes across codebase
Automated formatting and lint corrections from parallel agent work: - cargo fmt: import reordering (alphabetical), line wrapping to respect max width, trailing comma normalization, destructuring alignment, function signature reformatting, match arm formatting - clippy (pedantic): Range::contains() instead of manual comparisons, i64::from() instead of `as i64` casts, .clamp() instead of .max().min() chains, let-chain refactors (if-let with &&), #[allow(clippy::too_many_arguments)] and #[allow(clippy::field_reassign_with_default)] where warranted - Removed trailing blank lines and extra whitespace No behavioral changes. All existing tests pass unmodified. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,13 +51,24 @@ fn insert_document(conn: &Connection, id: i64, source_type: &str, title: &str, c
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn lexical_mode_uses_fts_only() {
|
||||
let (_tmp, conn) = create_test_db();
|
||||
|
||||
insert_document(&conn, 1, "issue", "Authentication bug", "OAuth token refresh fails silently.");
|
||||
insert_document(&conn, 2, "issue", "Database migration", "Migration script crashes on PostgreSQL.");
|
||||
insert_document(
|
||||
&conn,
|
||||
1,
|
||||
"issue",
|
||||
"Authentication bug",
|
||||
"OAuth token refresh fails silently.",
|
||||
);
|
||||
insert_document(
|
||||
&conn,
|
||||
2,
|
||||
"issue",
|
||||
"Database migration",
|
||||
"Migration script crashes on PostgreSQL.",
|
||||
);
|
||||
|
||||
let filters = SearchFilters {
|
||||
limit: 10,
|
||||
@@ -121,14 +132,23 @@ fn lexical_mode_no_embeddings_required() {
|
||||
.unwrap();
|
||||
|
||||
let results = search_fts(&conn, "testing", 10, FtsQueryMode::Safe).unwrap();
|
||||
assert!(!results.is_empty(), "FTS should work without embeddings tables");
|
||||
assert!(
|
||||
!results.is_empty(),
|
||||
"FTS should work without embeddings tables"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hybrid_mode_degrades_to_fts_without_client() {
|
||||
let (_tmp, conn) = create_test_db();
|
||||
|
||||
insert_document(&conn, 1, "issue", "Performance issue", "Application is slow under load.");
|
||||
insert_document(
|
||||
&conn,
|
||||
1,
|
||||
"issue",
|
||||
"Performance issue",
|
||||
"Application is slow under load.",
|
||||
);
|
||||
|
||||
let filters = SearchFilters {
|
||||
limit: 10,
|
||||
@@ -150,7 +170,11 @@ fn hybrid_mode_degrades_to_fts_without_client() {
|
||||
assert!(!results.is_empty(), "Should fall back to FTS results");
|
||||
// Should warn about missing Ollama client
|
||||
assert!(
|
||||
warnings.iter().any(|w| w.to_lowercase().contains("vector") || w.to_lowercase().contains("ollama") || w.to_lowercase().contains("client") || w.to_lowercase().contains("fallback") || w.to_lowercase().contains("fts")),
|
||||
warnings.iter().any(|w| w.to_lowercase().contains("vector")
|
||||
|| w.to_lowercase().contains("ollama")
|
||||
|| w.to_lowercase().contains("client")
|
||||
|| w.to_lowercase().contains("fallback")
|
||||
|| w.to_lowercase().contains("fts")),
|
||||
"Should produce a degradation warning, got: {:?}",
|
||||
warnings
|
||||
);
|
||||
@@ -177,8 +201,20 @@ fn rrf_ranking_combines_signals() {
|
||||
fn filters_by_source_type() {
|
||||
let (_tmp, conn) = create_test_db();
|
||||
|
||||
insert_document(&conn, 1, "issue", "Bug report", "Authentication bug in login flow.");
|
||||
insert_document(&conn, 2, "merge_request", "Fix auth", "Fixed authentication issue.");
|
||||
insert_document(
|
||||
&conn,
|
||||
1,
|
||||
"issue",
|
||||
"Bug report",
|
||||
"Authentication bug in login flow.",
|
||||
);
|
||||
insert_document(
|
||||
&conn,
|
||||
2,
|
||||
"merge_request",
|
||||
"Fix auth",
|
||||
"Fixed authentication issue.",
|
||||
);
|
||||
|
||||
let filters = SearchFilters {
|
||||
source_type: Some(lore::documents::SourceType::Issue),
|
||||
@@ -189,7 +225,11 @@ fn filters_by_source_type() {
|
||||
let all_ids = vec![1, 2];
|
||||
let filtered = lore::search::apply_filters(&conn, &all_ids, &filters).unwrap();
|
||||
|
||||
assert_eq!(filtered.len(), 1, "Filter should remove non-issue documents");
|
||||
assert_eq!(
|
||||
filtered.len(),
|
||||
1,
|
||||
"Filter should remove non-issue documents"
|
||||
);
|
||||
assert_eq!(filtered[0], 1, "Only issue document should remain");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user