fix(core): resolve all Clippy warnings

- Replace redundant closures with function references (webdav.rs, sync.rs)
- Use is_some_and instead of map_or(false, ...) (sync.rs)
- Use map instead of and_then(|x| Some(...)) (sync.rs)
- Use if-let instead of single-arm match (webdav.rs)
This commit is contained in:
Tristan Michael 2026-03-30 16:29:47 -07:00 committed by GitButler
parent 60fbbd75b8
commit c32a6fbe8b
2 changed files with 7 additions and 8 deletions

View file

@ -173,7 +173,7 @@ pub fn compute_sync_actions(
// Remote present, local gone, base known: local was deleted
(None, Some(_), Some(b)) => {
let remote_changed = remote.map_or(false, |r| r.size != b.size || r.last_modified.as_deref() != b.modified_at.as_deref());
let remote_changed = remote.is_some_and(|r| r.size != b.size || r.last_modified.as_deref() != b.modified_at.as_deref());
if remote_changed {
// deleted locally + modified remotely -> download (remote wins)
actions.push(SyncAction::Download { path: path.to_string() });
@ -374,9 +374,9 @@ fn scan_dir_recursive(root: &Path, dir: &Path, files: &mut Vec<LocalFileInfo>) -
let data = std::fs::read(&path)?;
let metadata = std::fs::metadata(&path)?;
let modified = metadata.modified().ok()
.and_then(|t| {
.map(|t| {
let dt: DateTime<Utc> = t.into();
Some(dt.to_rfc3339())
dt.to_rfc3339()
});
files.push(LocalFileInfo {
@ -540,7 +540,7 @@ pub async fn sync_workspace(
// Save queue with remaining failed actions
let new_queue = OfflineQueue {
operations: failed_actions.iter().map(|a| action_to_queued_op(a)).collect(),
operations: failed_actions.iter().map(action_to_queued_op).collect(),
};
new_queue.save(workspace_path)?;

View file

@ -37,7 +37,7 @@ impl WebDavClient {
// Percent-encode path segments while preserving '/'
let encoded: String = path
.split('/')
.map(|seg| percent_encode(seg))
.map(percent_encode)
.collect::<Vec<_>>()
.join("/");
format!("{}/{}", self._base_url, encoded)
@ -405,9 +405,8 @@ pub fn load_credentials(domain: &str) -> Result<(String, String)> {
let pass_entry = keyring::Entry::new(&service, "password")
.map_err(|e| Error::Credential(format!("Failed to create keyring entry: {}", e)))?;
match (user_entry.get_password(), pass_entry.get_password()) {
(Ok(user), Ok(pass)) => return Ok((user, pass)),
_ => {}
if let (Ok(user), Ok(pass)) = (user_entry.get_password(), pass_entry.get_password()) {
return Ok((user, pass));
}
// Fallback to env vars for headless/CI environments