Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon committed Apr 11, 2022
1 parent 5d5367f commit 47a9f8e
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions checks/evaluation/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package evaluation

import (
"fmt"

"github.com/ossf/scorecard/v4/checker"
sce "github.com/ossf/scorecard/v4/errors"
)
Expand All @@ -29,22 +27,19 @@ func License(name string, dl checker.DetailLogger,
e := sce.WithMessage(sce.ErrScorecardInternal, "empty raw data")
return checker.CreateRuntimeErrorResult(name, e)
}
// We expect a single license.
if len(r.Files) > 1 {
e := sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("invalid number of results: %d",
len(r.Files)))
return checker.CreateRuntimeErrorResult(name, e)
}

if len(r.Files) == 0 {
// Apply the policy evaluation.
if r.Files == nil || len(r.Files) == 0 {
return checker.CreateMinScoreResult(name, "license file not detected")
}

dl.Info(&checker.LogMessage{
Path: r.Files[0].Path,
Type: checker.FileTypeSource,
Offset: 1,
})
for _, f := range r.Files {
dl.Info(&checker.LogMessage{
Path: f.Path,
Type: checker.FileTypeSource,
Offset: 1,
})
}

return checker.CreateMaxScoreResult(name, "license file detected")
}

0 comments on commit 47a9f8e

Please sign in to comment.