Skip to content

Commit

Permalink
Add code to satisfy golint
Browse files Browse the repository at this point in the history
  • Loading branch information
riteshnoronha committed Aug 21, 2024
1 parent dc750fe commit a25510c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
12 changes: 10 additions & 2 deletions pkg/logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ func InitProdLogger() {
log.Fatalf("Failed to initialize logger: %v", err)
}

defer l.Sync()
defer func() {
if err := logger.Sync(); err != nil {
return
}
}()

if logger != nil {
panic("logger already initialized")
Expand All @@ -45,7 +49,11 @@ func InitDebugLogger() {
log.Printf("Failed to zap new development: %v", err)
}

defer l.Sync()
defer func() {
if err := logger.Sync(); err != nil {
return
}
}()

if logger != nil {
panic("logger already initialized")
Expand Down
31 changes: 9 additions & 22 deletions pkg/sbom/spdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ func (s *SpdxDoc) parseComps() {
nc.Supplier = *supp
}

// https://github.com/spdx/ntia-conformance-checker/issues/100
// Add spdx support to check both supplier and originator
if supp == nil && manu != nil {
nc.Supplier.Name = manu.Name
nc.Supplier.Email = manu.Email
}

if sc.PackageVerificationCode != nil {
nc.sourceCodeHash = sc.PackageVerificationCode.Value
}
Expand Down Expand Up @@ -574,6 +581,8 @@ func (s *SpdxDoc) getManufacturer(index int) *manufacturer {
}
}

// https://github.com/spdx/ntia-conformance-checker/issues/100
// Add spdx support to check both supplier and originator
func (s *SpdxDoc) getSupplier(index int) *Supplier {
pkg := s.doc.Packages[index]

Expand All @@ -596,28 +605,6 @@ func (s *SpdxDoc) getSupplier(index int) *Supplier {
}
}

// https://github.com/spdx/ntia-conformance-checker/issues/100
// Add spdx support to check both supplier and originator
func (s *SpdxDoc) addSupplierName(index int) string {
supplier := s.getSupplier(index)
manufacturer := s.getManufacturer(index)

if supplier == nil && manufacturer == nil {
s.addToLogs(fmt.Sprintf("spdx doc pkg %s at index %d no supplier/originator found", s.doc.Packages[index].PackageName, index))
return ""
}

if supplier != nil {
return supplier.Name
}

if manufacturer != nil {
return manufacturer.Name
}

return ""
}

func (s *SpdxDoc) parsePrimaryComponent() {
pkgIDs := make(map[string]*spdx.Package)

Expand Down

0 comments on commit a25510c

Please sign in to comment.