Skip to content

Commit

Permalink
prevent detecting duplicate licenses in a single LICENSE file
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon committed Apr 26, 2023
1 parent 2d4d950 commit 67592db
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions licenses/classifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,20 @@ func (c *googleClassifier) Identify(licensePath string) ([]License, error) {
return nil, err
}

foundLicenseNames := map[string]struct{}{}

licenses := []License{}
for _, match := range matches.Matches {
if match.MatchType != "License" {
continue
}

// Skip duplicate licenses.
if _, ok := foundLicenseNames[match.Name]; ok {
continue
}
foundLicenseNames[match.Name] = struct{}{}

licenses = append(licenses, License{
Name: match.Name,
Type: LicenseType(match.Name),
Expand All @@ -84,6 +92,12 @@ func (c *googleClassifier) Identify(licensePath string) ([]License, error) {
continue
}

// Skip duplicate licenses.
if _, ok := foundLicenseNames[match.Name]; ok {
continue
}
foundLicenseNames[match.Name] = struct{}{}

licenses = append(licenses, License{
Name: match.Name,
Type: LicenseType(match.Name),
Expand Down

0 comments on commit 67592db

Please sign in to comment.