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:
Taylor Eernisse
2026-02-03 13:01:59 -05:00
parent ff94f24702
commit a50fc78823
42 changed files with 1431 additions and 623 deletions

View File

@@ -557,10 +557,7 @@ impl GitLabClient {
/// all pages into a Vec rather than using streaming.
impl GitLabClient {
/// Fetch all pages from a paginated endpoint, returning collected results.
async fn fetch_all_pages<T: serde::de::DeserializeOwned>(
&self,
path: &str,
) -> Result<Vec<T>> {
async fn fetch_all_pages<T: serde::de::DeserializeOwned>(&self, path: &str) -> Result<Vec<T>> {
let mut results = Vec::new();
let mut page = 1u32;
let per_page = 100u32;
@@ -571,9 +568,7 @@ impl GitLabClient {
("page", page.to_string()),
];
let (items, headers) = self
.request_with_headers::<Vec<T>>(path, &params)
.await?;
let (items, headers) = self.request_with_headers::<Vec<T>>(path, &params).await?;
let is_empty = items.is_empty();
let full_page = items.len() as u32 == per_page;
@@ -604,9 +599,8 @@ impl GitLabClient {
gitlab_project_id: i64,
iid: i64,
) -> Result<Vec<GitLabStateEvent>> {
let path = format!(
"/api/v4/projects/{gitlab_project_id}/issues/{iid}/resource_state_events"
);
let path =
format!("/api/v4/projects/{gitlab_project_id}/issues/{iid}/resource_state_events");
self.fetch_all_pages(&path).await
}
@@ -616,9 +610,8 @@ impl GitLabClient {
gitlab_project_id: i64,
iid: i64,
) -> Result<Vec<GitLabLabelEvent>> {
let path = format!(
"/api/v4/projects/{gitlab_project_id}/issues/{iid}/resource_label_events"
);
let path =
format!("/api/v4/projects/{gitlab_project_id}/issues/{iid}/resource_label_events");
self.fetch_all_pages(&path).await
}
@@ -628,9 +621,8 @@ impl GitLabClient {
gitlab_project_id: i64,
iid: i64,
) -> Result<Vec<GitLabMilestoneEvent>> {
let path = format!(
"/api/v4/projects/{gitlab_project_id}/issues/{iid}/resource_milestone_events"
);
let path =
format!("/api/v4/projects/{gitlab_project_id}/issues/{iid}/resource_milestone_events");
self.fetch_all_pages(&path).await
}
@@ -676,18 +668,30 @@ impl GitLabClient {
gitlab_project_id: i64,
entity_type: &str,
iid: i64,
) -> Result<(Vec<GitLabStateEvent>, Vec<GitLabLabelEvent>, Vec<GitLabMilestoneEvent>)> {
) -> Result<(
Vec<GitLabStateEvent>,
Vec<GitLabLabelEvent>,
Vec<GitLabMilestoneEvent>,
)> {
match entity_type {
"issue" => {
let state = self.fetch_issue_state_events(gitlab_project_id, iid).await?;
let label = self.fetch_issue_label_events(gitlab_project_id, iid).await?;
let milestone = self.fetch_issue_milestone_events(gitlab_project_id, iid).await?;
let state = self
.fetch_issue_state_events(gitlab_project_id, iid)
.await?;
let label = self
.fetch_issue_label_events(gitlab_project_id, iid)
.await?;
let milestone = self
.fetch_issue_milestone_events(gitlab_project_id, iid)
.await?;
Ok((state, label, milestone))
}
"merge_request" => {
let state = self.fetch_mr_state_events(gitlab_project_id, iid).await?;
let label = self.fetch_mr_label_events(gitlab_project_id, iid).await?;
let milestone = self.fetch_mr_milestone_events(gitlab_project_id, iid).await?;
let milestone = self
.fetch_mr_milestone_events(gitlab_project_id, iid)
.await?;
Ok((state, label, milestone))
}
_ => Err(LoreError::Other(format!(
@@ -750,23 +754,23 @@ mod tests {
#[test]
fn cursor_rewind_clamps_to_zero() {
let updated_after = Some(1000i64); // 1 second
let updated_after = 1000i64; // 1 second
let cursor_rewind_seconds = 10u32; // 10 seconds
// Rewind would be negative, should clamp to 0
let rewind_ms = (cursor_rewind_seconds as i64) * 1000;
let rewound = (updated_after.unwrap() - rewind_ms).max(0);
let rewind_ms = i64::from(cursor_rewind_seconds) * 1000;
let rewound = (updated_after - rewind_ms).max(0);
assert_eq!(rewound, 0);
}
#[test]
fn cursor_rewind_applies_correctly() {
let updated_after = Some(1705312800000i64); // 2024-01-15T10:00:00.000Z
let updated_after = 1705312800000i64; // 2024-01-15T10:00:00.000Z
let cursor_rewind_seconds = 60u32; // 1 minute
let rewind_ms = (cursor_rewind_seconds as i64) * 1000;
let rewound = (updated_after.unwrap() - rewind_ms).max(0);
let rewind_ms = i64::from(cursor_rewind_seconds) * 1000;
let rewound = (updated_after - rewind_ms).max(0);
// Should be 1 minute earlier
assert_eq!(rewound, 1705312740000);