@@ -247,23 +247,23 @@ impl Validate for Bom {
247247
248248 if let Some ( metadata) = & self . metadata {
249249 if let Some ( component) = & metadata. component {
250- validate_component_bom_refs ( & mut context, & mut bom_refs, component) ;
250+ context = validate_component_bom_refs ( context, & mut bom_refs, component) ;
251251 }
252252 }
253253
254254 if let Some ( components) = & self . components {
255- validate_components ( & mut context, & mut bom_refs, components) ;
255+ context = validate_components ( context, & mut bom_refs, components) ;
256256 }
257257
258258 if let Some ( services) = & self . services {
259- validate_services ( & mut context, & mut bom_refs, services) ;
259+ context = validate_services ( context, & mut bom_refs, services) ;
260260 }
261261
262262 // Check dependencies & sub dependencies
263263 if let Some ( dependencies) = & self . dependencies {
264264 for dependency in & dependencies. 0 {
265265 if !bom_refs. contains ( & dependency. dependency_ref ) {
266- context. add_custom (
266+ context = context . add_custom (
267267 "dependency_ref" ,
268268 format ! (
269269 "Dependency ref '{}' does not exist in the BOM" ,
@@ -274,7 +274,7 @@ impl Validate for Bom {
274274
275275 for sub_dependency in & dependency. dependencies {
276276 if !bom_refs. contains ( sub_dependency) {
277- context. add_custom (
277+ context = context . add_custom (
278278 "sub dependency_ref" ,
279279 format ! (
280280 "Dependency ref '{}' does not exist in the BOM" ,
@@ -289,10 +289,10 @@ impl Validate for Bom {
289289 // Check compositions, its dependencies & assemblies
290290 if let Some ( compositions) = & self . compositions {
291291 for composition in & compositions. 0 {
292- if let Some ( assemblies) = composition. assemblies {
293- for BomReference ( assembly) in & assemblies {
292+ if let Some ( assemblies) = & composition. assemblies {
293+ for BomReference ( assembly) in assemblies {
294294 if !bom_refs. contains ( assembly) {
295- context. add_custom (
295+ context = context . add_custom (
296296 "composition ref" ,
297297 format ! (
298298 "Composition reference '{assembly}' does not exist in the BOM"
@@ -305,7 +305,7 @@ impl Validate for Bom {
305305 if let Some ( dependencies) = & composition. dependencies {
306306 for BomReference ( dependency) in dependencies {
307307 if !bom_refs. contains ( & dependency) {
308- context. add_custom (
308+ context = context . add_custom (
309309 "composition ref" ,
310310 format ! (
311311 "Composition reference '{dependency}' does not exist in the BOM"
@@ -343,57 +343,65 @@ impl BomReferencesContext {
343343
344344/// Validates the Bom references.
345345fn validate_component_bom_refs (
346- context : & mut ValidationContext ,
346+ mut context : ValidationContext ,
347347 bom_refs : & mut BomReferencesContext ,
348348 component : & Component ,
349- ) {
349+ ) -> ValidationContext {
350350 if let Some ( bom_ref) = & component. bom_ref {
351351 if bom_refs. contains ( & bom_ref) {
352- context. add_custom ( "bom_ref" , format ! ( r#"Bom ref "{bom_ref}" is not unique"# ) ) ;
352+ context =
353+ context. add_custom ( "bom_ref" , format ! ( r#"Bom ref "{bom_ref}" is not unique"# ) ) ;
353354 }
354355 bom_refs. add_component_bom_ref ( bom_ref) ;
355356 }
356357
357358 if let Some ( components) = & component. components {
358- validate_components ( context, bom_refs, components) ;
359+ context = validate_components ( context, bom_refs, components) ;
359360 }
361+
362+ context
360363}
361364
362365fn validate_components (
363- context : & mut ValidationContext ,
366+ mut context : ValidationContext ,
364367 bom_refs : & mut BomReferencesContext ,
365368 components : & Components ,
366- ) {
369+ ) -> ValidationContext {
367370 for component in & components. 0 {
368- validate_component_bom_refs ( context, bom_refs, component) ;
371+ context = validate_component_bom_refs ( context, bom_refs, component) ;
369372 }
373+ context
370374}
371375
372376fn validate_services (
373- context : & mut ValidationContext ,
377+ mut context : ValidationContext ,
374378 bom_refs : & mut BomReferencesContext ,
375379 services : & Services ,
376- ) {
380+ ) -> ValidationContext {
377381 for service in & services. 0 {
378- validate_service_bom_refs ( context, bom_refs, service) ;
382+ context = validate_service_bom_refs ( context, bom_refs, service) ;
379383 }
384+ context
380385}
381386
382387fn validate_service_bom_refs (
383- context : & mut ValidationContext ,
388+ mut context : ValidationContext ,
384389 bom_refs : & mut BomReferencesContext ,
385390 service : & Service ,
386- ) {
391+ ) -> ValidationContext {
387392 if let Some ( bom_ref) = & service. bom_ref {
388393 if bom_refs. contains ( bom_ref) {
389- context. add_custom ( "bom_ref" , format ! ( r#"Bom ref "{bom_ref}" is not unique"# ) ) ;
394+ context =
395+ context. add_custom ( "bom_ref" , format ! ( r#"Bom ref "{bom_ref}" is not unique"# ) ) ;
390396 }
391397 bom_refs. add_service_bom_ref ( bom_ref) ;
392398 }
393399
394400 if let Some ( services) = & service. services {
395- validate_services ( context, bom_refs, services) ;
401+ context = validate_services ( context, bom_refs, services) ;
396402 }
403+
404+ context
397405}
398406
399407#[ derive( Clone , Debug , PartialEq , Eq ) ]
0 commit comments