Add fixes made by cargo clippy

This commit is contained in:
Nikolai Rodionov 2024-01-10 18:15:13 +01:00
parent c07e3f57ea
commit 6fa97f2e4a
Signed by: allanger
GPG Key ID: 0AA46A90E25592AD
4 changed files with 16 additions and 16 deletions

View File

@ -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",
));
))
}
}
}

View File

@ -172,12 +172,12 @@ fn patch_action_from_definition(
patch: Patch,
) -> Result<Box<dyn PatchInterface>, Box<dyn std::error::Error>> {
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 {

View File

@ -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) => {

View File

@ -37,7 +37,7 @@ pub(crate) struct Version {
pub(crate) fn repo_from_chart(chart: Chart) -> Result<Box<dyn Repo>, Box<dyn std::error::Error>> {
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<dyn Repo>, Box<dyn std
}
}
}
Err(err) => return Err(Box::from(err)),
};
Err(err) => Err(err),
}
}