From efec43b3b8827820cf35fe1b73d8e33f5fe84eb4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 20 Jun 2026 01:16:50 +0900 Subject: refactor: auto-fix clippy warnings --- crates/shirabe/src/repository/vcs/svn_driver.rs | 47 ++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'crates/shirabe/src/repository/vcs/svn_driver.rs') diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index b48ce99..6346a84 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -168,33 +168,32 @@ impl SvnDriver { identifier: &str, ) -> Result>> { if !self.inner.info_cache.contains_key(identifier) { - if self.should_cache(identifier) { - if let Some(mut res) = self + if self.should_cache(identifier) + && let Some(mut res) = self .inner .cache .as_mut() .and_then(|c| c.read(&format!("{}.json", identifier))) - { - // old cache files had '' stored instead of null due to af3783b5f40bae32a23e353eaf0a00c9b8ce82e2, so we make sure here that we always return null or array - // and fix outdated invalid cache files - if res == "\"\"" { - res = "null".to_string(); - self.inner - .cache - .as_mut() - .unwrap() - .write(&format!("{}.json", identifier), &res)?; - } - - let parsed = JsonFile::parse_json(Some(res.as_str()), None)?; - let composer: Option> = parsed - .as_array() - .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect()); + { + // old cache files had '' stored instead of null due to af3783b5f40bae32a23e353eaf0a00c9b8ce82e2, so we make sure here that we always return null or array + // and fix outdated invalid cache files + if res == "\"\"" { + res = "null".to_string(); self.inner - .info_cache - .insert(identifier.to_string(), composer.clone()); - return Ok(composer); + .cache + .as_mut() + .unwrap() + .write(&format!("{}.json", identifier), &res)?; } + + let parsed = JsonFile::parse_json(Some(res.as_str()), None)?; + let composer: Option> = parsed + .as_array() + .map(|m| m.iter().map(|(k, v)| (k.clone(), (**v).clone())).collect()); + self.inner + .info_cache + .insert(identifier.to_string(), composer.clone()); + return Ok(composer); } let base_result = @@ -290,7 +289,7 @@ impl SvnDriver { return Err(e); } }; - if trim(&output, None) == "" { + if trim(&output, None).is_empty() { return Ok(None); } @@ -506,14 +505,14 @@ impl SvnDriver { } // Subversion client 1.7 and older - if stripos(&process.get_error_output(), "authorization failed:").is_some() { + if stripos(process.get_error_output(), "authorization failed:").is_some() { // This is likely a remote Subversion repository that requires // authentication. We will handle actual authentication later. return Ok(true); } // Subversion client 1.8 and newer - if stripos(&process.get_error_output(), "Authentication failed").is_some() { + if stripos(process.get_error_output(), "Authentication failed").is_some() { // This is likely a remote Subversion or newer repository that requires // authentication. We will handle actual authentication later. return Ok(true); -- cgit v1.3.1