From 6fa97f2e4acacbbe013ae9e3053020041b605b43 Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Wed, 10 Jan 2024 18:15:13 +0100 Subject: [PATCH] Add fixes made by cargo clippy --- src/config/mod.rs | 18 +++++++++--------- src/config/patch.rs | 6 +++--- src/main.rs | 2 +- src/source/mod.rs | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 1820475..8fe96ce 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -116,7 +116,7 @@ impl Chart { } //let err = error!("repo {} is not found in the repo list", self.repository); let error_msg = format!("repo {} is not found in the repo list", self.repository); - return Err(Box::from(error_msg)); + Err(Box::from(error_msg)) } // TODO: Handle the "mirror not found" error pub(crate) fn populate_mirrors( @@ -132,7 +132,7 @@ impl Chart { } } } - if mirror_objs.len() > 0 { + if !mirror_objs.is_empty() { self.mirror_objs = Some(mirror_objs); } Ok(()) @@ -143,7 +143,7 @@ impl Chart { Some(res) => res.helm.unwrap().url, None => { warn!("repository object is not filled for chart {}", self.name); - return "".to_string(); + "".to_string() } } } @@ -153,7 +153,7 @@ impl Chart { Some(res) => res.git.unwrap().url, None => { warn!("repository object is not filled for chart {}", self.name); - return "".to_string(); + "".to_string() } } } @@ -163,7 +163,7 @@ impl Chart { Some(res) => res.git.unwrap().git_ref, None => { warn!("repository object is not filled for chart {}", self.name); - return "".to_string(); + "".to_string() } } } @@ -173,7 +173,7 @@ impl Chart { Some(res) => res.git.unwrap().path, None => { warn!("repository object is not filled for chart {}", self.name); - return "".to_string(); + "".to_string() } } } @@ -182,7 +182,7 @@ impl Chart { match &self.repository_obj { Some(res) => { if res.helm.is_some() { - return Ok(RepositoryKind::Helm); + Ok(RepositoryKind::Helm) } else if res.git.is_some() { return Ok(RepositoryKind::Git); } else { @@ -190,9 +190,9 @@ impl Chart { } } None => { - return Err(Box::from( + Err(Box::from( "repository object is not filled up for the chart", - )); + )) } } } diff --git a/src/config/patch.rs b/src/config/patch.rs index d3b02c0..db99573 100644 --- a/src/config/patch.rs +++ b/src/config/patch.rs @@ -172,12 +172,12 @@ fn patch_action_from_definition( patch: Patch, ) -> Result, Box> { if let Some(regexp) = patch.regexp { - return Ok(Box::new(RegexpPatch { path: regexp.path })); + Ok(Box::new(RegexpPatch { path: regexp.path })) } else if let Some(git) = patch.git { return Ok(Box::new(GitPatch { path: { let path = PathBuf::from(git.path); - let can_path = fs::canonicalize(&path).ok().unwrap(); + let can_path = fs::canonicalize(path).ok().unwrap(); can_path.into_os_string().into_string().ok().unwrap() }, })); @@ -192,7 +192,7 @@ fn patch_action_from_definition( return Ok(Box::from(yq)); } else { return Err(Box::from("unknown patch type")); - }; + } } fn is_git_repo(path: String) -> bool { diff --git a/src/main.rs b/src/main.rs index 0367306..95a0d88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,7 @@ fn main() { Some(res) => match create_dir(res.clone()) { Ok(_) => { let path = PathBuf::from(res); - let can_path = fs::canonicalize(&path).ok().unwrap(); + let can_path = fs::canonicalize(path).ok().unwrap(); can_path.into_os_string().into_string().ok().unwrap() } Err(err) => { diff --git a/src/source/mod.rs b/src/source/mod.rs index 6e37d06..9d62199 100644 --- a/src/source/mod.rs +++ b/src/source/mod.rs @@ -37,7 +37,7 @@ pub(crate) struct Version { pub(crate) fn repo_from_chart(chart: Chart) -> Result, Box> { match chart.get_repo_kind() { Ok(res) => { - return match res { + match res { crate::config::RepositoryKind::Helm => { let helm: helm::Helm = chart.into(); Ok(Box::new(helm)) @@ -48,6 +48,6 @@ pub(crate) fn repo_from_chart(chart: Chart) -> Result, Box return Err(Box::from(err)), - }; + Err(err) => Err(err), + } }