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:
@@ -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, ¶ms)
|
||||
.await?;
|
||||
let (items, headers) = self.request_with_headers::<Vec<T>>(path, ¶ms).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);
|
||||
|
||||
@@ -179,10 +179,7 @@ fn transform_single_note(
|
||||
resolvable: note.resolvable,
|
||||
resolved: note.resolved,
|
||||
resolved_by: note.resolved_by.as_ref().map(|a| a.username.clone()),
|
||||
resolved_at: note
|
||||
.resolved_at
|
||||
.as_ref()
|
||||
.and_then(|ts| iso_to_ms(ts)),
|
||||
resolved_at: note.resolved_at.as_ref().and_then(|ts| iso_to_ms(ts)),
|
||||
position_old_path,
|
||||
position_new_path,
|
||||
position_old_line,
|
||||
@@ -235,7 +232,6 @@ fn extract_position_fields(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Transform notes from a GitLab discussion with strict timestamp parsing.
|
||||
/// Returns Err if any timestamp is invalid - no silent fallback to 0.
|
||||
pub fn transform_notes_with_diff_position(
|
||||
|
||||
Reference in New Issue
Block a user