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:
@@ -10,7 +10,7 @@ use rusqlite::Connection;
|
||||
use serde::Deserialize;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use lore::search::{self, FtsQueryMode, SearchFilters, SearchMode, search_fts, apply_filters};
|
||||
use lore::search::{FtsQueryMode, SearchFilters, SearchMode, apply_filters, search_fts};
|
||||
|
||||
/// A golden query test case.
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -35,8 +35,7 @@ struct GoldenFilters {
|
||||
}
|
||||
|
||||
fn load_golden_queries() -> Vec<GoldenQuery> {
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("tests/fixtures/golden_queries.json");
|
||||
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/golden_queries.json");
|
||||
let content = std::fs::read_to_string(&path)
|
||||
.unwrap_or_else(|_| panic!("Failed to read golden queries fixture"));
|
||||
serde_json::from_str(&content)
|
||||
@@ -77,63 +76,88 @@ fn create_seeded_db() -> Connection {
|
||||
// Seed deterministic documents
|
||||
let documents = vec![
|
||||
// id=1: Auth issue (matches: authentication, login, OAuth, JWT, token, refresh)
|
||||
(1, "issue", "Authentication and login broken with OAuth",
|
||||
"Users cannot login when using OAuth tokens. The JWT token refresh fails silently, \
|
||||
(
|
||||
1,
|
||||
"issue",
|
||||
"Authentication and login broken with OAuth",
|
||||
"Users cannot login when using OAuth tokens. The JWT token refresh fails silently, \
|
||||
causing authentication errors. When the access token expires, the refresh flow returns \
|
||||
a 401 instead of fetching new credentials. Login page shows a generic error. \
|
||||
Multiple users reported authentication failures across all OAuth providers.",
|
||||
"testuser"),
|
||||
|
||||
"testuser",
|
||||
),
|
||||
// id=2: User profile MR (matches: user, profile, avatar, upload)
|
||||
(2, "merge_request", "Add user profile page with avatar upload",
|
||||
"This merge request adds a new user profile page. Users can now upload their avatar, \
|
||||
(
|
||||
2,
|
||||
"merge_request",
|
||||
"Add user profile page with avatar upload",
|
||||
"This merge request adds a new user profile page. Users can now upload their avatar, \
|
||||
edit their display name, and manage notification preferences. The profile page includes \
|
||||
responsive design for mobile and desktop viewports.",
|
||||
"developer1"),
|
||||
|
||||
"developer1",
|
||||
),
|
||||
// id=3: Database migration issue (matches: database, migration, PostgreSQL, schema)
|
||||
(3, "issue", "Database migration failing on PostgreSQL 14",
|
||||
"The database migration script crashes on PostgreSQL 14 due to deprecated syntax. \
|
||||
(
|
||||
3,
|
||||
"issue",
|
||||
"Database migration failing on PostgreSQL 14",
|
||||
"The database migration script crashes on PostgreSQL 14 due to deprecated syntax. \
|
||||
The ALTER TABLE command uses a syntax removed in PG14. Migration 042 needs to be \
|
||||
rewritten to use the new schema modification syntax. All staging environments affected.",
|
||||
"dba_admin"),
|
||||
|
||||
"dba_admin",
|
||||
),
|
||||
// id=4: Performance MR (matches: performance, optimization, caching, query)
|
||||
(4, "merge_request", "Performance optimization for dashboard queries",
|
||||
"Optimized the dashboard query performance by adding database indexes and implementing \
|
||||
(
|
||||
4,
|
||||
"merge_request",
|
||||
"Performance optimization for dashboard queries",
|
||||
"Optimized the dashboard query performance by adding database indexes and implementing \
|
||||
Redis caching for frequently accessed reports. Query execution time reduced from 3.2s \
|
||||
to 180ms. Added connection pooling and prepared statement caching.",
|
||||
"senior_dev"),
|
||||
|
||||
"senior_dev",
|
||||
),
|
||||
// id=5: API rate limiting discussion (matches: API, rate, limiting, throttle)
|
||||
(5, "discussion", "API rate limiting strategies for public endpoints",
|
||||
"Discussion about implementing API rate limiting on public-facing endpoints. \
|
||||
(
|
||||
5,
|
||||
"discussion",
|
||||
"API rate limiting strategies for public endpoints",
|
||||
"Discussion about implementing API rate limiting on public-facing endpoints. \
|
||||
Proposed approaches: token bucket with sliding window, fixed window counters, \
|
||||
or leaky bucket algorithm. Rate limits should be configurable per API key tier. \
|
||||
Need to handle burst traffic during peak hours without throttling legitimate users.",
|
||||
"architect"),
|
||||
|
||||
"architect",
|
||||
),
|
||||
// id=6: UI/CSS issue (matches: CSS, styling, frontend, responsive, UI)
|
||||
(6, "issue", "CSS styling issues on mobile frontend",
|
||||
"Multiple CSS styling problems on the mobile frontend. The navigation menu overlaps \
|
||||
(
|
||||
6,
|
||||
"issue",
|
||||
"CSS styling issues on mobile frontend",
|
||||
"Multiple CSS styling problems on the mobile frontend. The navigation menu overlaps \
|
||||
content on screens smaller than 768px. Button text truncates on compact viewports. \
|
||||
Frontend responsive breakpoints need adjustment. The UI components library has \
|
||||
conflicting CSS specificity with the theme system.",
|
||||
"frontend_dev"),
|
||||
|
||||
"frontend_dev",
|
||||
),
|
||||
// id=7: CI/CD MR (matches: CI, CD, pipeline, deployment, Docker)
|
||||
(7, "merge_request", "Revamp CI/CD pipeline with Docker caching",
|
||||
"Complete overhaul of the CI/CD pipeline. Added Docker layer caching to speed up \
|
||||
(
|
||||
7,
|
||||
"merge_request",
|
||||
"Revamp CI/CD pipeline with Docker caching",
|
||||
"Complete overhaul of the CI/CD pipeline. Added Docker layer caching to speed up \
|
||||
builds. Deployment stages now run in parallel where possible. Added rollback \
|
||||
support for failed deployments. Pipeline runtime reduced from 45min to 12min.",
|
||||
"devops_lead"),
|
||||
|
||||
"devops_lead",
|
||||
),
|
||||
// id=8: Security issue (matches: security, vulnerability, XSS, injection)
|
||||
(8, "issue", "Security vulnerability in form submission",
|
||||
"A cross-site scripting (XSS) vulnerability was found in the comment submission form. \
|
||||
(
|
||||
8,
|
||||
"issue",
|
||||
"Security vulnerability in form submission",
|
||||
"A cross-site scripting (XSS) vulnerability was found in the comment submission form. \
|
||||
User input is not properly sanitized before rendering. The security scanner also flagged \
|
||||
potential SQL injection in the search endpoint. Both vulnerabilities need immediate patching.",
|
||||
"security_team"),
|
||||
"security_team",
|
||||
),
|
||||
];
|
||||
|
||||
for (id, source_type, title, content, author) in &documents {
|
||||
@@ -213,7 +237,11 @@ fn golden_queries_all_pass() {
|
||||
if filtered_ids.len() < gq.min_results {
|
||||
failures.push(format!(
|
||||
"FAIL [{}] \"{}\": expected >= {} results, got {} (description: {})",
|
||||
i, gq.query, gq.min_results, filtered_ids.len(), gq.description
|
||||
i,
|
||||
gq.query,
|
||||
gq.min_results,
|
||||
filtered_ids.len(),
|
||||
gq.description
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user