Skip to content

Commit

Permalink
Merge pull request #75 from rumenvasilev/master
Browse files Browse the repository at this point in the history
introduce unknown license list
  • Loading branch information
sagikazarmark authored Sep 12, 2023
2 parents ebf1aee + 1f891ca commit 85e05ed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/cmd/licensei/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type checkOptions struct {
approved []string
unknown []string
ignored []string

githubToken string
Expand All @@ -27,6 +28,7 @@ func NewCheckCommand() *cobra.Command {
Short: "Check licenses of dependencies in the project",
RunE: func(_ *cobra.Command, _ []string) error {
options.approved = viper.GetStringSlice("approved")
options.unknown = viper.GetStringSlice("unknown")
options.ignored = viper.GetStringSlice("ignored")

options.githubToken = viper.GetString("github_token")
Expand Down Expand Up @@ -71,12 +73,20 @@ func runCheck(options checkOptions) error {

for _, dep := range dependencies {
var approved bool
var unknown bool

for _, license := range options.approved {
approved = approved || strings.EqualFold(license, dep.License)
}

if _, ignore := ignored[dep.Name]; !approved && !ignore {
// check for no licence
for _, v := range options.unknown {
if strings.EqualFold(v, dep.Name) && strings.EqualFold("", dep.License) {
unknown = unknown || true
}
}

if _, ignore := ignored[dep.Name]; !approved && !unknown && !ignore {
violations = append(violations, dep)
}
}
Expand Down

0 comments on commit 85e05ed

Please sign in to comment.