Skip to content

Commit dc93a4b

Browse files
committed
145 clippy errors eliminated.
1 parent 3727687 commit dc93a4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+158
-178
lines changed

vcs-worker/src/database.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ impl Database {
225225

226226
match matches.len() {
227227
0 => Err(ObjectsTreeError::SerializationError(
228-
format!("Change ID '{}' not found", short_or_full)
228+
format!("Change ID '{short_or_full}' not found")
229229
)),
230230
1 => Ok(matches[0].clone()),
231231
_ => Err(ObjectsTreeError::SerializationError(
232-
format!("Ambiguous change ID prefix '{}' matches multiple changes. Please provide more characters.", short_or_full)
232+
format!("Ambiguous change ID prefix '{short_or_full}' matches multiple changes. Please provide more characters.")
233233
)),
234234
}
235235
}

vcs-worker/src/object_diff.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ pub fn compare_object_versions(database: &DatabaseRef, obj_name: &str, local_ver
259259
// Get the local version content
260260
let local_sha256 = database.refs().get_ref(VcsObjectType::MooObject, obj_name, Some(local_version))
261261
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
262-
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Local version {} of object '{}' not found", local_version, obj_name)))?;
262+
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Local version {local_version} of object '{obj_name}' not found")))?;
263263

264264
let local_content = database.objects().get(&local_sha256)
265265
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
266-
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Object content for SHA256 '{}' not found", local_sha256)))?;
266+
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Object content for SHA256 '{local_sha256}' not found")))?;
267267

268268
// Parse local object definition
269269
let local_def = database.objects().parse_object_dump(&local_content)
@@ -272,15 +272,15 @@ pub fn compare_object_versions(database: &DatabaseRef, obj_name: &str, local_ver
272272
// Get the baseline version (previous version)
273273
// For version 1 (new object), there is no baseline (version 0 doesn't exist)
274274
// For version 2+, the baseline is the previous version
275-
let baseline_version = if local_version > 1 { local_version - 1 } else { 0 };
275+
let baseline_version = local_version.saturating_sub(1);
276276
let baseline_sha256 = database.refs().get_ref(VcsObjectType::MooObject, obj_name, Some(baseline_version))
277277
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?;
278278

279279
if let Some(baseline_sha256) = baseline_sha256 {
280280
// Get baseline content and parse it
281281
let baseline_content = database.objects().get(&baseline_sha256)
282282
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
283-
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Baseline object content for SHA256 '{}' not found", baseline_sha256)))?;
283+
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Baseline object content for SHA256 '{baseline_sha256}' not found")))?;
284284

285285
let baseline_def = database.objects().parse_object_dump(&baseline_content)
286286
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?;

vcs-worker/src/operations/change/change_abandon_op.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl ChangeAbandonOperation {
2929
if let Some(change_id) = top_change_id {
3030
let change = self.database.index().get_change(&change_id)
3131
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
32-
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Top change '{}' not found", change_id)))?;
32+
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Top change '{change_id}' not found")))?;
3333

3434
info!("Attempting to abandon current change: {}", change.id);
3535

@@ -59,9 +59,9 @@ impl ChangeAbandonOperation {
5959
Ok(undo_delta)
6060
} else {
6161
error!("No current change to abandon");
62-
return Err(ObjectsTreeError::SerializationError(
62+
Err(ObjectsTreeError::SerializationError(
6363
"Error: No change to abandon".to_string()
64-
));
64+
))
6565
}
6666
}
6767

@@ -154,7 +154,7 @@ player:tell("Change abandoned. You need to revert ", length(diff["modified_objec
154154
}
155155
Err(e) => {
156156
error!("Change abandon operation failed: {}", e);
157-
moor_var::v_error(moor_var::E_INVARG.msg(&format!("Error: {e}")))
157+
moor_var::v_error(moor_var::E_INVARG.msg(format!("Error: {e}")))
158158
}
159159
}
160160
}

vcs-worker/src/operations/change/change_approve_op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl ChangeApproveOperation {
4545
self.database.index().get_change(&change_id)
4646
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
4747
.ok_or_else(|| ObjectsTreeError::SerializationError(
48-
format!("Change '{}' not found in workspace or index", change_id)
48+
format!("Change '{change_id}' not found in workspace or index")
4949
))?
5050
}
5151
};
@@ -268,7 +268,7 @@ player:tell("Added: ", length(diff["added_objects"]), " objects");"#.to_string()
268268
}
269269
Err(e) => {
270270
error!("Change approve operation failed: {}", e);
271-
v_error(E_INVARG.msg(&format!("Error: {e}")))
271+
v_error(E_INVARG.msg(format!("Error: {e}")))
272272
}
273273
}
274274
}

vcs-worker/src/operations/change/change_create_op.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl Operation for ChangeCreateOperation {
195195
}
196196
Err(e) => {
197197
error!("Change create operation failed: {}", e);
198-
moor_var::v_error(moor_var::E_INVARG.msg(&format!("Error: {e}")))
198+
moor_var::v_error(moor_var::E_INVARG.msg(format!("Error: {e}")))
199199
}
200200
}
201201
}

vcs-worker/src/operations/change/change_stash_op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl ChangeStashOperation {
3939
// Get the change
4040
let mut change = self.database.index().get_change(&top_change_id)
4141
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
42-
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Change '{}' not found", top_change_id)))?;
42+
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Change '{top_change_id}' not found")))?;
4343

4444
info!("User '{}' attempting to stash change: {} ({})", user.id, change.name, change.id);
4545

@@ -174,7 +174,7 @@ worker_request("vcs", {"change/switch", stashed_id});"#.to_string(),
174174
}
175175
Err(e) => {
176176
error!("Change stash operation failed: {}", e);
177-
v_error(E_INVARG.msg(&format!("Error: {e}")))
177+
v_error(E_INVARG.msg(format!("Error: {e}")))
178178
}
179179
}
180180
}

vcs-worker/src/operations/change/change_status_op.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl ChangeStatusOperation {
4747
// Get the actual change object
4848
let current_change = self.database.index().get_change(&change_id)
4949
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
50-
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Change '{}' not found", change_id)))?;
50+
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Change '{change_id}' not found")))?;
5151

5252
// Check if the top change is local status
5353
if current_change.status != ChangeStatus::Local {
@@ -68,7 +68,7 @@ impl ChangeStatusOperation {
6868
Ok(status_map)
6969
} else {
7070
info!("No top change found, returning error");
71-
return Ok(v_error(E_INVARG.msg("No change on top of index - nothing to do")));
71+
Ok(v_error(E_INVARG.msg("No change on top of index - nothing to do")))
7272
}
7373
}
7474

@@ -161,7 +161,7 @@ player:tell("Deleted: ", length(diff["deleted_objects"]), " objects");"#.to_stri
161161
}
162162
Err(e) => {
163163
error!("Change status operation failed: {}", e);
164-
moor_var::v_error(moor_var::E_INVARG.msg(&format!("Error: {e}")))
164+
moor_var::v_error(moor_var::E_INVARG.msg(format!("Error: {e}")))
165165
}
166166
}
167167
}

vcs-worker/src/operations/change/change_submit_op.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl ChangeSubmitOperation {
3939
// Get the change
4040
let mut change = self.database.index().get_change(&top_change_id)
4141
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
42-
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Change '{}' not found", top_change_id)))?;
42+
.ok_or_else(|| ObjectsTreeError::SerializationError(format!("Change '{top_change_id}' not found")))?;
4343

4444
info!("User '{}' attempting to submit change: {} ({})", user.id, change.name, change.id);
4545

@@ -167,16 +167,16 @@ impl ChangeSubmitOperation {
167167
fn submit_to_remote(&self, source_url: &str, change: &crate::types::Change, _user: &User) -> Result<(), ObjectsTreeError> {
168168
// Build the URL for the remote workspace/submit endpoint
169169
let submit_url = if source_url.ends_with('/') {
170-
format!("{}workspace/submit", source_url)
170+
format!("{source_url}workspace/submit")
171171
} else {
172-
format!("{}/workspace/submit", source_url)
172+
format!("{source_url}/workspace/submit")
173173
};
174174

175175
info!("Submitting change '{}' to remote URL: {}", change.id, submit_url);
176176

177177
// Serialize the change to a JSON string
178178
let serialized_change = serde_json::to_string(change)
179-
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to serialize change: {}", e)))?;
179+
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to serialize change: {e}")))?;
180180

181181
// Prepare the payload for the workspace/submit operation
182182
// The operation expects args[0] to be the serialized change
@@ -195,21 +195,21 @@ impl ChangeSubmitOperation {
195195
let client = reqwest::blocking::Client::builder()
196196
.timeout(std::time::Duration::from_secs(30))
197197
.build()
198-
.map_err(|e| format!("Failed to create HTTP client: {}", e))?;
198+
.map_err(|e| format!("Failed to create HTTP client: {e}"))?;
199199

200200
// Make the PUT request to workspace/submit
201201
let response = client
202202
.put(&url_clone)
203203
.json(&payload_clone)
204204
.send()
205-
.map_err(|e| format!("HTTP request failed: {}", e))?;
205+
.map_err(|e| format!("HTTP request failed: {e}"))?;
206206

207207
if response.status().is_success() {
208208
Ok(())
209209
} else {
210210
let status = response.status();
211211
let error_text = response.text().unwrap_or_else(|_| "Unknown error".to_string());
212-
Err(format!("Remote submission failed with status {}: {}", status, error_text))
212+
Err(format!("Remote submission failed with status {status}: {error_text}"))
213213
}
214214
})
215215
.join()
@@ -346,7 +346,7 @@ diff = worker_request("vcs", {"change/submit"});
346346
}
347347
Err(e) => {
348348
error!("Change submit operation failed: {}", e);
349-
v_error(E_INVARG.msg(&format!("Error: {e}")))
349+
v_error(E_INVARG.msg(format!("Error: {e}")))
350350
}
351351
}
352352
}

vcs-worker/src/operations/change/change_switch_op.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl ChangeSwitchOperation {
3232
let mut target_change = self.database.workspace().get_workspace_change(&target_change_id)
3333
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
3434
.ok_or_else(|| ObjectsTreeError::SerializationError(
35-
format!("Change '{}' not found in workspace", target_change_id)
35+
format!("Change '{target_change_id}' not found in workspace")
3636
))?;
3737

3838
info!("Found target change '{}' in workspace (status: {:?})", target_change.name, target_change.status);
@@ -49,7 +49,7 @@ impl ChangeSwitchOperation {
4949
let mut current_change = self.database.index().get_change(&current_change_id)
5050
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?
5151
.ok_or_else(|| ObjectsTreeError::SerializationError(
52-
format!("Current change '{}' not found", current_change_id)
52+
format!("Current change '{current_change_id}' not found")
5353
))?;
5454

5555
// Only handle local changes - can't switch away from merged/review changes
@@ -226,7 +226,7 @@ player:tell("Need to update ", length(diff["modified_objects"]), " objects");"#.
226226
}
227227
Err(e) => {
228228
error!("Workspace change switch operation failed: {}", e);
229-
v_error(E_INVARG.msg(&format!("Error: {e}")))
229+
v_error(E_INVARG.msg(format!("Error: {e}")))
230230
}
231231
}
232232
}

vcs-worker/src/operations/clone_op.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl CloneOperation {
8080
.header("X-API-Key", api_key)
8181
.send()
8282
.await
83-
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to stat remote server: {}", e)))?;
83+
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to stat remote server: {e}")))?;
8484

8585
if !response.status().is_success() {
8686
return Err(ObjectsTreeError::SerializationError(
@@ -90,7 +90,7 @@ impl CloneOperation {
9090

9191
let response_json: serde_json::Value = response.json()
9292
.await
93-
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to parse stat response: {}", e)))?;
93+
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to parse stat response: {e}")))?;
9494

9595
// Extract user info from response
9696
// Response format: {"result": [user_id, email, v_obj, permissions], ...}
@@ -123,7 +123,7 @@ impl CloneOperation {
123123
let response = client.get(url)
124124
.send()
125125
.await
126-
.map_err(|e| ObjectsTreeError::SerializationError(format!("HTTP request failed: {}", e)))?;
126+
.map_err(|e| ObjectsTreeError::SerializationError(format!("HTTP request failed: {e}")))?;
127127

128128
if !response.status().is_success() {
129129
return Err(ObjectsTreeError::SerializationError(
@@ -133,7 +133,7 @@ impl CloneOperation {
133133

134134
let response_text = response.text()
135135
.await
136-
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to read response: {}", e)))?;
136+
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to read response: {e}")))?;
137137

138138
// Try to parse as OperationResponse first (HTTP API response)
139139
let clone_data: CloneData = if let Ok(op_response) = serde_json::from_str::<serde_json::Value>(&response_text) {
@@ -142,20 +142,20 @@ impl CloneOperation {
142142
if let Some(result_str) = result_field.as_str() {
143143
// The result is a JSON string, parse it as CloneData
144144
serde_json::from_str(result_str)
145-
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to parse CloneData from result: {}", e)))?
145+
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to parse CloneData from result: {e}")))?
146146
} else {
147147
// The result might be a direct object
148148
serde_json::from_value(result_field.clone())
149-
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to parse CloneData from result object: {}", e)))?
149+
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to parse CloneData from result object: {e}")))?
150150
}
151151
} else {
152152
// No result field, try to parse the whole response as CloneData
153153
serde_json::from_value(op_response)
154-
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to parse CloneData: {}", e)))?
154+
.map_err(|e| ObjectsTreeError::SerializationError(format!("Failed to parse CloneData: {e}")))?
155155
}
156156
} else {
157157
// Not valid JSON, return error
158-
return Err(ObjectsTreeError::SerializationError(format!("Invalid JSON response: {}", response_text)));
158+
return Err(ObjectsTreeError::SerializationError(format!("Invalid JSON response: {response_text}")));
159159
};
160160

161161
// Extract base URL from source_url (remove /api/clone or /clone suffix)
@@ -175,7 +175,7 @@ impl CloneOperation {
175175
// Import the data
176176
self.import_state(clone_data, url, external_user_info.as_ref())?;
177177

178-
Ok(format!("Successfully cloned from {}", url))
178+
Ok(format!("Successfully cloned from {url}"))
179179
}
180180

181181
/// Import repository state from a URL (sync wrapper for use in execute())
@@ -224,7 +224,7 @@ impl CloneOperation {
224224

225225
// Import refs
226226
for (obj_info, sha256) in &data.refs {
227-
self.database.refs().update_ref(obj_info.object_type, &obj_info.name, obj_info.version, &sha256)
227+
self.database.refs().update_ref(obj_info.object_type, &obj_info.name, obj_info.version, sha256)
228228
.map_err(|e| ObjectsTreeError::SerializationError(e.to_string()))?;
229229
}
230230
info!("Imported {} refs", refs_count);
@@ -396,13 +396,13 @@ impl Operation for CloneOperation {
396396
}
397397
Err(e) => {
398398
error!("Failed to serialize clone data: {}", e);
399-
v_error(E_INVARG.msg(&format!("Failed to serialize: {}", e)))
399+
v_error(E_INVARG.msg(format!("Failed to serialize: {e}")))
400400
}
401401
}
402402
}
403403
Err(e) => {
404404
error!("Failed to export repository state: {}", e);
405-
v_error(E_INVARG.msg(&format!("{}", e)))
405+
v_error(E_INVARG.msg(format!("{e}")))
406406
}
407407
}
408408
} else {
@@ -424,7 +424,7 @@ impl Operation for CloneOperation {
424424
}
425425
Err(e) => {
426426
error!("Clone operation failed: {}", e);
427-
v_error(E_INVARG.msg(&format!("{}", e)))
427+
v_error(E_INVARG.msg(format!("{e}")))
428428
}
429429
}
430430
}

0 commit comments

Comments
 (0)