Skip to content

Commit ac23b53

Browse files
committed
fix linting errors
Signed-off-by: Vivek Kumar Sahu <[email protected]>
1 parent 2556e37 commit ac23b53

File tree

3 files changed

+40
-53
lines changed

3 files changed

+40
-53
lines changed

pkg/compliance/bsi.go

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func bsiComponents(doc sbom.Document) []*db.Record {
352352
}
353353

354354
func bsiComponentDepth(doc sbom.Document, component sbom.GetComponent) *db.Record {
355-
result, score := "", SCORE_ZERO
355+
result, score := "", 0.0
356356
var dependencies []string
357357
var allDepByName []string
358358

@@ -369,17 +369,16 @@ func bsiComponentDepth(doc sbom.Document, component sbom.GetComponent) *db.Recor
369369
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "included-in", 10.0, "")
370370
}
371371
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationship", 0.0, "")
372-
} else {
373-
allDepByName = common.GetDependenciesByName(dependencies, bsiCompIDWithName)
374-
if bsiPrimaryDependencies[common.GetID(component.GetSpdxID())] {
375-
allDepByName = append([]string{"included-in"}, allDepByName...)
376-
result = strings.Join(allDepByName, ", ")
377-
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
378-
} else {
379-
result = strings.Join(allDepByName, ", ")
380-
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
381-
}
382372
}
373+
allDepByName = common.GetDependenciesByName(dependencies, bsiCompIDWithName)
374+
if bsiPrimaryDependencies[common.GetID(component.GetSpdxID())] {
375+
allDepByName = append([]string{"included-in"}, allDepByName...)
376+
result = strings.Join(allDepByName, ", ")
377+
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
378+
}
379+
result = strings.Join(allDepByName, ", ")
380+
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
381+
383382
} else if doc.Spec().GetSpecType() == "cyclonedx" {
384383
if component.GetPrimaryCompInfo().IsPresent() {
385384
result = strings.Join(bsiGetAllPrimaryDepenciesByName, ", ")
@@ -393,17 +392,15 @@ func bsiComponentDepth(doc sbom.Document, component sbom.GetComponent) *db.Recor
393392
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "included-in", 10.0, "")
394393
}
395394
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationship", 0.0, "")
396-
} else {
397-
allDepByName = common.GetDependenciesByName(dependencies, bsiCompIDWithName)
398-
if bsiPrimaryDependencies[id] {
399-
allDepByName = append([]string{"included-in"}, allDepByName...)
400-
result = strings.Join(allDepByName, ", ")
401-
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
402-
} else {
403-
result = strings.Join(allDepByName, ", ")
404-
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
405-
}
406395
}
396+
allDepByName = common.GetDependenciesByName(dependencies, bsiCompIDWithName)
397+
if bsiPrimaryDependencies[id] {
398+
allDepByName = append([]string{"included-in"}, allDepByName...)
399+
result = strings.Join(allDepByName, ", ")
400+
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
401+
}
402+
result = strings.Join(allDepByName, ", ")
403+
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
407404
}
408405

409406
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationships", 0.0, "")

pkg/compliance/common/common.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,6 @@ func CheckCopyright(cp string) (string, bool) {
266266
return cp, cp != "NOASSERTION" && cp != "NONE"
267267
}
268268

269-
func GetPrimaryDependencies(component sbom.GetComponent) {
270-
}
271-
272269
// ComponentsLists return component lists as a map
273270
func ComponentsLists(doc sbom.Document) map[string]bool {
274271
componentList := make(map[string]bool)

pkg/compliance/ntia.go

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,6 @@ func ntiaSbomCreatedTimestamp(doc sbom.Document) *db.Record {
219219
return db.NewRecordStmt(SBOM_TIMESTAMP, "SBOM Data Fields", result, score, "")
220220
}
221221

222-
func extractName(comp string) string {
223-
for x, y := range compIDWithName {
224-
if strings.Contains(comp, x) {
225-
return y
226-
}
227-
}
228-
return ""
229-
}
230-
231222
var (
232223
compIDWithName = make(map[string]string)
233224
componentList = make(map[string]bool)
@@ -328,21 +319,24 @@ func ntiaComponentDependencies(doc sbom.Document, component sbom.GetComponent) *
328319

329320
dependencies = doc.GetRelationships(component.GetID())
330321
if dependencies == nil {
322+
331323
if primaryDependencies[common.GetID(component.GetSpdxID())] {
332324
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "included-in", 10.0, "")
333325
}
334326
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationship", 0.0, "")
335-
} else {
336-
allDepByName = common.GetDependenciesByName(dependencies, compIDWithName)
337-
if primaryDependencies[common.GetID(component.GetSpdxID())] {
338-
allDepByName = append([]string{"included-in"}, allDepByName...)
339-
result = strings.Join(allDepByName, ", ")
340-
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
341-
} else {
342-
result = strings.Join(allDepByName, ", ")
343-
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
344-
}
327+
345328
}
329+
allDepByName = common.GetDependenciesByName(dependencies, compIDWithName)
330+
331+
if primaryDependencies[common.GetID(component.GetSpdxID())] {
332+
allDepByName = append([]string{"included-in"}, allDepByName...)
333+
result = strings.Join(allDepByName, ", ")
334+
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
335+
}
336+
337+
result = strings.Join(allDepByName, ", ")
338+
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
339+
346340
} else if doc.Spec().GetSpecType() == "cyclonedx" {
347341
if component.GetPrimaryCompInfo().IsPresent() {
348342
result = strings.Join(getAllPrimaryDepenciesByName, ", ")
@@ -356,17 +350,16 @@ func ntiaComponentDependencies(doc sbom.Document, component sbom.GetComponent) *
356350
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "included-in", 10.0, "")
357351
}
358352
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationship", 0.0, "")
359-
} else {
360-
allDepByName = common.GetDependenciesByName(dependencies, compIDWithName)
361-
if primaryDependencies[id] {
362-
allDepByName = append([]string{"included-in"}, allDepByName...)
363-
result = strings.Join(allDepByName, ", ")
364-
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
365-
} else {
366-
result = strings.Join(allDepByName, ", ")
367-
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
368-
}
369353
}
354+
allDepByName = common.GetDependenciesByName(dependencies, compIDWithName)
355+
if primaryDependencies[id] {
356+
allDepByName = append([]string{"included-in"}, allDepByName...)
357+
result = strings.Join(allDepByName, ", ")
358+
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
359+
}
360+
result = strings.Join(allDepByName, ", ")
361+
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
362+
370363
}
371364
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, score, "")
372365
}

0 commit comments

Comments
 (0)