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:
@@ -65,7 +65,7 @@ pub fn get_pending_fetches(conn: &Connection, limit: usize) -> Result<Vec<Pendin
|
||||
FROM pending_discussion_fetches
|
||||
WHERE next_attempt_at IS NULL OR next_attempt_at <= ?1
|
||||
ORDER BY queued_at ASC
|
||||
LIMIT ?2"
|
||||
LIMIT ?2",
|
||||
)?;
|
||||
let rows = stmt
|
||||
.query_map(rusqlite::params![now, limit as i64], |row| {
|
||||
@@ -137,7 +137,15 @@ pub fn record_fetch_error(
|
||||
last_error = ?3,
|
||||
next_attempt_at = ?4
|
||||
WHERE project_id = ?5 AND noteable_type = ?6 AND noteable_iid = ?7",
|
||||
rusqlite::params![new_attempt, now, error, next_at, project_id, noteable_type.as_str(), noteable_iid],
|
||||
rusqlite::params![
|
||||
new_attempt,
|
||||
now,
|
||||
error,
|
||||
next_at,
|
||||
project_id,
|
||||
noteable_type.as_str(),
|
||||
noteable_iid
|
||||
],
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -196,18 +204,24 @@ mod tests {
|
||||
queue_discussion_fetch(&conn, 1, NoteableType::Issue, 42).unwrap();
|
||||
record_fetch_error(&conn, 1, NoteableType::Issue, 42, "network error").unwrap();
|
||||
|
||||
let attempt: i32 = conn.query_row(
|
||||
"SELECT attempt_count FROM pending_discussion_fetches WHERE noteable_iid = 42",
|
||||
[], |r| r.get(0),
|
||||
).unwrap();
|
||||
let attempt: i32 = conn
|
||||
.query_row(
|
||||
"SELECT attempt_count FROM pending_discussion_fetches WHERE noteable_iid = 42",
|
||||
[],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(attempt, 1);
|
||||
|
||||
// Re-queue should reset
|
||||
queue_discussion_fetch(&conn, 1, NoteableType::Issue, 42).unwrap();
|
||||
let attempt: i32 = conn.query_row(
|
||||
"SELECT attempt_count FROM pending_discussion_fetches WHERE noteable_iid = 42",
|
||||
[], |r| r.get(0),
|
||||
).unwrap();
|
||||
let attempt: i32 = conn
|
||||
.query_row(
|
||||
"SELECT attempt_count FROM pending_discussion_fetches WHERE noteable_iid = 42",
|
||||
[],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(attempt, 0);
|
||||
}
|
||||
|
||||
@@ -230,9 +244,11 @@ mod tests {
|
||||
queue_discussion_fetch(&conn, 1, NoteableType::Issue, 42).unwrap();
|
||||
complete_fetch(&conn, 1, NoteableType::Issue, 42).unwrap();
|
||||
|
||||
let count: i64 = conn.query_row(
|
||||
"SELECT COUNT(*) FROM pending_discussion_fetches", [], |r| r.get(0),
|
||||
).unwrap();
|
||||
let count: i64 = conn
|
||||
.query_row("SELECT COUNT(*) FROM pending_discussion_fetches", [], |r| {
|
||||
r.get(0)
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(count, 0);
|
||||
}
|
||||
|
||||
@@ -249,17 +265,23 @@ mod tests {
|
||||
assert_eq!(attempt, 1);
|
||||
assert_eq!(error, Some("timeout".to_string()));
|
||||
|
||||
let next_at: Option<i64> = conn.query_row(
|
||||
"SELECT next_attempt_at FROM pending_discussion_fetches WHERE noteable_iid = 10",
|
||||
[], |r| r.get(0),
|
||||
).unwrap();
|
||||
let next_at: Option<i64> = conn
|
||||
.query_row(
|
||||
"SELECT next_attempt_at FROM pending_discussion_fetches WHERE noteable_iid = 10",
|
||||
[],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(next_at.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_noteable_type_parse() {
|
||||
assert_eq!(NoteableType::parse("Issue"), Some(NoteableType::Issue));
|
||||
assert_eq!(NoteableType::parse("MergeRequest"), Some(NoteableType::MergeRequest));
|
||||
assert_eq!(
|
||||
NoteableType::parse("MergeRequest"),
|
||||
Some(NoteableType::MergeRequest)
|
||||
);
|
||||
assert_eq!(NoteableType::parse("invalid"), None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user