Skip to content

Commit e140b1b

Browse files
committed
refactor(scan/local): drop redundant empty-name guard in OS PURL override
purl.New now returns (nil, nil) when the package has no name, so the explicit `if detail.Packages[i].Name == ""` check is no longer required — the existing `if p == nil { continue }` covers it.
1 parent 9dc4ab0 commit e140b1b

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

pkg/scan/local/service.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@ func (s Service) Scan(ctx context.Context, targetName, artifactKey string, blobK
9393

9494
// Override OS packages PURL to update the distro,
9595
// preserving the correlation between the OS and package PURLs.
96+
// purl.New returns (nil, nil) when the package has no name (e.g. local
97+
// package.json), so no extra guard is needed here.
9698
for i := range detail.Packages {
97-
// Skip packages without a name (e.g. local package.json) — PURL would be incorrect.
98-
if detail.Packages[i].Name == "" {
99-
continue
100-
}
10199
p, err := purl.New(detail.OS.Family, types.Metadata{OS: &detail.OS}, detail.Packages[i])
102100
if err != nil {
103101
log.Error("Failed to create PackageURL", log.Err(err))

0 commit comments

Comments
 (0)