From 32903e9909f17dc806d4f21fd83ec08fb57b75ce Mon Sep 17 00:00:00 2001 From: louib Date: Thu, 24 Aug 2023 10:39:25 -0400 Subject: [PATCH] refactor: move away from chaining --- src/cyclone_dx.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/cyclone_dx.rs b/src/cyclone_dx.rs index 818c31d..f249c2e 100644 --- a/src/cyclone_dx.rs +++ b/src/cyclone_dx.rs @@ -110,15 +110,12 @@ fn get_commits(patches: &Vec) -> Vec { fn get_external_references(package_node: &crate::nix::PackageNode) -> Vec { let mut external_references: Vec = vec![]; for homepage in package_node.package.meta.get_homepages() { + let mut external_reference_builder = ExternalReferenceBuilder::default(); // See https://docs.rs/serde-cyclonedx/latest/serde_cyclonedx/cyclonedx/v_1_5/struct.ExternalReference.html#structfield.type_ // for all the available external reference types - external_references.push( - ExternalReferenceBuilder::default() - .type_("website") - .url(homepage.to_string()) - .build() - .unwrap(), - ); + external_reference_builder.type_("website"); + external_reference_builder.url(homepage.to_string()); + external_references.push(external_reference_builder.build().unwrap()); } for source in &package_node.sources { let source_url = match source.get_url() { @@ -127,13 +124,10 @@ fn get_external_references(package_node: &crate::nix::PackageNode) -> Vec