From b3bb417047a71d1c4b0efe18a337f9bb613d1dab Mon Sep 17 00:00:00 2001 From: Geoffrey Arthaud <geoffrey.arthaud@developpement-durable.gouv.fr> Date: Thu, 29 Feb 2024 22:14:33 +0100 Subject: [PATCH] Fix clippy warnings --- .gitlab-ci-local-variables.yml | 4 ++++ src/diagnosis/container_analysis.rs | 6 +----- src/diagnosis/package_analysis.rs | 8 +++----- src/diagnosis/pipeline_analysis.rs | 14 +++++--------- 4 files changed, 13 insertions(+), 19 deletions(-) create mode 100644 .gitlab-ci-local-variables.yml diff --git a/.gitlab-ci-local-variables.yml b/.gitlab-ci-local-variables.yml new file mode 100644 index 0000000..ccf211b --- /dev/null +++ b/.gitlab-ci-local-variables.yml @@ -0,0 +1,4 @@ +--- + +DEBUG: 'true' +TEST_OPTIONS: '--help' \ No newline at end of file diff --git a/src/diagnosis/container_analysis.rs b/src/diagnosis/container_analysis.rs index ba95504..d5155f0 100644 --- a/src/diagnosis/container_analysis.rs +++ b/src/diagnosis/container_analysis.rs @@ -120,11 +120,7 @@ impl ReportJob for ContainerAnalysisJob { gitlab::api::paged(endpoint, Pagination::All).query(&self.gitlab); match query { Err(e) => self.into_report( - vec![ReportStatus::ERROR(format!( - "{} {}", - fl!("error"), - e.to_string() - ))], + vec![ReportStatus::ERROR(format!("{} {}", fl!("error"), e))], vec![], ), Ok(containers) => { diff --git a/src/diagnosis/package_analysis.rs b/src/diagnosis/package_analysis.rs index 6f8073f..f3faddb 100644 --- a/src/diagnosis/package_analysis.rs +++ b/src/diagnosis/package_analysis.rs @@ -99,11 +99,9 @@ impl ReportJob for PackageAnalysisJob { let query: Result<Vec<GitlabPackage>, _> = gitlab::api::paged(endpoint, Pagination::All).query(&self.gitlab); match query { - Err(e) => self.default_report(ReportStatus::ERROR(format!( - "{} {}", - fl!("error"), - e.to_string() - ))), + Err(e) => { + self.default_report(ReportStatus::ERROR(format!("{} {}", fl!("error"), e))) + } Ok(mut packages) => { packages.sort_by(|a, b| b.created_at.partial_cmp(&a.created_at).unwrap()); let mut savable_bytes = 0; diff --git a/src/diagnosis/pipeline_analysis.rs b/src/diagnosis/pipeline_analysis.rs index 06a1e5d..46ad7f8 100644 --- a/src/diagnosis/pipeline_analysis.rs +++ b/src/diagnosis/pipeline_analysis.rs @@ -32,7 +32,7 @@ impl Reportable for PipelineAnalysisReport { } impl PipelineAnalysisJob { - fn to_report( + fn into_report( self, report_status: Vec<ReportStatus>, pipelines: Vec<GitlabPipeline>, @@ -54,7 +54,7 @@ impl ReportJob for PipelineAnalysisJob { pending_msg: fl!("pipeline-analysing"), job: std::thread::spawn(move || { if !self.project.jobs_enabled { - return self.to_report(vec![ReportStatus::NA(fl!("no-cicd"))], vec![]); + return self.into_report(vec![ReportStatus::NA(fl!("no-cicd"))], vec![]); } let endpoint = gitlab::api::projects::pipelines::Pipelines::builder() @@ -64,19 +64,15 @@ impl ReportJob for PipelineAnalysisJob { let query: Result<Vec<GitlabPipeline>, _> = gitlab::api::paged(endpoint, Pagination::All).query(&self.gitlab); match query { - Err(e) => self.to_report( - vec![ReportStatus::ERROR(format!( - "{} {}", - fl!("error"), - e.to_string() - ))], + Err(e) => self.into_report( + vec![ReportStatus::ERROR(format!("{} {}", fl!("error"), e))], vec![], ), Ok(mut pipelines) => { let days = self.days; let ref_date = Local::now() - Duration::days(days as i64); pipelines.sort_by(|a, b| a.created_at.partial_cmp(&b.created_at).unwrap()); - self.to_report( + self.into_report( vec![ReportStatus::NA(fl!( "pipeline-report", total_pipelines = pipelines.len(), -- GitLab