From e1157dcd675a3acbbcc5099244dd75047ea13529 Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Fri, 27 Oct 2023 09:24:23 +0800 Subject: [PATCH 01/11] added new list for MPL 2.0 Signed-off-by: Patrick Zheng --- assets/compatibility/Apache-2.0.yaml | 3 +++ pkg/deps/check.go | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/assets/compatibility/Apache-2.0.yaml b/assets/compatibility/Apache-2.0.yaml index 752f871..118d8c8 100644 --- a/assets/compatibility/Apache-2.0.yaml +++ b/assets/compatibility/Apache-2.0.yaml @@ -89,3 +89,6 @@ incompatible: - CPOL-1.02 - NPL-1.0 - NPL-1.1 + +compatible-with-conditions: + - MPL-2.0 \ No newline at end of file diff --git a/pkg/deps/check.go b/pkg/deps/check.go index f5c663a..1c5ec5e 100644 --- a/pkg/deps/check.go +++ b/pkg/deps/check.go @@ -30,8 +30,9 @@ import ( ) type CompatibilityMatrix struct { - Compatible []string `yaml:"compatible"` - Incompatible []string `yaml:"incompatible"` + Compatible []string `yaml:"compatible"` + Incompatible []string `yaml:"incompatible"` + CompatibleWithConditions []string `yaml:"compatible-with-conditions"` } var matrices = make(map[string]CompatibilityMatrix) @@ -108,7 +109,7 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo switch operator { case LicenseOperatorAND: if compareAll(spdxIDs, func(spdxID string) bool { - return compare(matrix.Compatible, spdxID) + return compare(matrix.Compatible, spdxID) || compare(matrix.CompatibleWithConditions, spdxID) }) { continue } @@ -120,7 +121,7 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo case LicenseOperatorOR: if compareAny(spdxIDs, func(spdxID string) bool { - return compare(matrix.Compatible, spdxID) + return compare(matrix.Compatible, spdxID) || compare(matrix.CompatibleWithConditions, spdxID) }) { continue } From 7ec7d1bcd5ae89ca3b70914cf9acdf3f2c6edd9f Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Fri, 27 Oct 2023 10:02:42 +0800 Subject: [PATCH 02/11] test Signed-off-by: Patrick Zheng --- pkg/deps/check.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/deps/check.go b/pkg/deps/check.go index 1c5ec5e..5da2b1b 100644 --- a/pkg/deps/check.go +++ b/pkg/deps/check.go @@ -105,7 +105,8 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo var unknownResults []*Result for _, result := range append(report.Resolved, report.Skipped...) { operator, spdxIDs := parseLicenseExpression(result.LicenseSpdxID) - + fmt.Printf("Result: %+v\n", result) + fmt.Println("operator:", operator) switch operator { case LicenseOperatorAND: if compareAll(spdxIDs, func(spdxID string) bool { From 0be2be39d0ddf4eb8d78ce3b3a902c70a19323e8 Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Fri, 27 Oct 2023 10:22:42 +0800 Subject: [PATCH 03/11] test Signed-off-by: Patrick Zheng --- pkg/deps/check.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/deps/check.go b/pkg/deps/check.go index 5da2b1b..0ab1f43 100644 --- a/pkg/deps/check.go +++ b/pkg/deps/check.go @@ -105,7 +105,7 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo var unknownResults []*Result for _, result := range append(report.Resolved, report.Skipped...) { operator, spdxIDs := parseLicenseExpression(result.LicenseSpdxID) - fmt.Printf("Result: %+v\n", result) + fmt.Println("spdxIDs:", spdxIDs) fmt.Println("operator:", operator) switch operator { case LicenseOperatorAND: From a64b1147f3dddc5c897cc3f8b8a6edceb56a5a5e Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Fri, 27 Oct 2023 10:31:59 +0800 Subject: [PATCH 04/11] test Signed-off-by: Patrick Zheng --- pkg/deps/check.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/deps/check.go b/pkg/deps/check.go index 0ab1f43..bf2566d 100644 --- a/pkg/deps/check.go +++ b/pkg/deps/check.go @@ -106,6 +106,7 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo for _, result := range append(report.Resolved, report.Skipped...) { operator, spdxIDs := parseLicenseExpression(result.LicenseSpdxID) fmt.Println("spdxIDs:", spdxIDs) + fmt.Println("result.LicenseSpdxID:", result.LicenseSpdxID) fmt.Println("operator:", operator) switch operator { case LicenseOperatorAND: From eb0d9f52673d783482ade631804c61e0acd9a18a Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Fri, 27 Oct 2023 10:35:21 +0800 Subject: [PATCH 05/11] test Signed-off-by: Patrick Zheng --- pkg/deps/check.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/deps/check.go b/pkg/deps/check.go index bf2566d..62370f7 100644 --- a/pkg/deps/check.go +++ b/pkg/deps/check.go @@ -134,7 +134,7 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo } default: - if compatible := compare(matrix.Compatible, spdxIDs[0]); compatible { + if compatible := compare(matrix.Compatible, spdxIDs[0]) || compare(matrix.CompatibleWithConditions, spdxIDs[0]); compatible { continue } if incompatible := compare(matrix.Incompatible, spdxIDs[0]); incompatible { From 1ad301081c74901e15df3431840fb46cd564f1fe Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Tue, 31 Oct 2023 10:02:51 +0800 Subject: [PATCH 06/11] added compatible-with-conditions flag to deps check Signed-off-by: Patrick Zheng --- commands/deps_check.go | 8 +++++++- pkg/deps/check.go | 25 ++++++++++++++++--------- pkg/deps/check_test.go | 42 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/commands/deps_check.go b/commands/deps_check.go index 8073d0b..d6c5284 100644 --- a/commands/deps_check.go +++ b/commands/deps_check.go @@ -26,6 +26,12 @@ import ( "github.com/apache/skywalking-eyes/pkg/deps" ) +var compatibleWithConditions bool + +func init() { + DepsCheckCommand.PersistentFlags().BoolVarP(&compatibleWithConditions, "compatible-with-conditions", "cc", false, "if set, include compatible-with-conditions list in dependencies checking") +} + var DepsCheckCommand = &cobra.Command{ Use: "check", Aliases: []string{"c"}, @@ -34,7 +40,7 @@ var DepsCheckCommand = &cobra.Command{ var errors []error configDeps := Config.Dependencies() for _, header := range Config.Headers() { - if err := deps.Check(header.License.SpdxID, configDeps); err != nil { + if err := deps.Check(header.License.SpdxID, configDeps, compatibleWithConditions); err != nil { errors = append(errors, err) } } diff --git a/pkg/deps/check.go b/pkg/deps/check.go index 62370f7..6dd97c6 100644 --- a/pkg/deps/check.go +++ b/pkg/deps/check.go @@ -64,7 +64,7 @@ func init() { } } -func Check(mainLicenseSpdxID string, config *ConfigDeps) error { +func Check(mainLicenseSpdxID string, config *ConfigDeps, compatibleWithConditions bool) error { matrix := matrices[mainLicenseSpdxID] report := Report{} @@ -72,7 +72,7 @@ func Check(mainLicenseSpdxID string, config *ConfigDeps) error { return nil } - return CheckWithMatrix(mainLicenseSpdxID, &matrix, &report) + return CheckWithMatrix(mainLicenseSpdxID, &matrix, &report, compatibleWithConditions) } func compare(list []string, spdxID string) bool { @@ -100,18 +100,19 @@ func compareAny(spdxIDs []string, compare func(spdxID string) bool) bool { return false } -func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, report *Report) error { +func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, report *Report, compatibleWithConditions bool) error { var incompatibleResults []*Result var unknownResults []*Result + fmt.Println("compatibleWithConditions:", compatibleWithConditions) for _, result := range append(report.Resolved, report.Skipped...) { operator, spdxIDs := parseLicenseExpression(result.LicenseSpdxID) - fmt.Println("spdxIDs:", spdxIDs) - fmt.Println("result.LicenseSpdxID:", result.LicenseSpdxID) - fmt.Println("operator:", operator) switch operator { case LicenseOperatorAND: if compareAll(spdxIDs, func(spdxID string) bool { - return compare(matrix.Compatible, spdxID) || compare(matrix.CompatibleWithConditions, spdxID) + if compatibleWithConditions { + return compare(matrix.Compatible, spdxID) || compare(matrix.CompatibleWithConditions, spdxID) + } + return compare(matrix.Compatible, spdxID) }) { continue } @@ -123,7 +124,10 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo case LicenseOperatorOR: if compareAny(spdxIDs, func(spdxID string) bool { - return compare(matrix.Compatible, spdxID) || compare(matrix.CompatibleWithConditions, spdxID) + if compatibleWithConditions { + return compare(matrix.Compatible, spdxID) || compare(matrix.CompatibleWithConditions, spdxID) + } + return compare(matrix.Compatible, spdxID) }) { continue } @@ -134,7 +138,10 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo } default: - if compatible := compare(matrix.Compatible, spdxIDs[0]) || compare(matrix.CompatibleWithConditions, spdxIDs[0]); compatible { + if compatible := compare(matrix.Compatible, spdxIDs[0]); compatible { + continue + } + if compatibleWithConditions && compare(matrix.CompatibleWithConditions, spdxIDs[0]) { continue } if incompatible := compare(matrix.Incompatible, spdxIDs[0]); incompatible { diff --git a/pkg/deps/check_test.go b/pkg/deps/check_test.go index db4a250..b7025db 100644 --- a/pkg/deps/check_test.go +++ b/pkg/deps/check_test.go @@ -18,9 +18,10 @@ package deps_test import ( - "github.com/apache/skywalking-eyes/pkg/deps" "strings" "testing" + + "github.com/apache/skywalking-eyes/pkg/deps" ) var TestMatrix = deps.CompatibilityMatrix{ @@ -52,6 +53,9 @@ var TestMatrix = deps.CompatibilityMatrix{ "GPL-2.0-only", "GPL-2.0-or-later", }, + CompatibleWithConditions: []string{ + "MPL-2.0", + }, } func TestCheckWithMatrix(t *testing.T) { @@ -62,7 +66,7 @@ func TestCheckWithMatrix(t *testing.T) { LicenseSpdxID: "Apache-2.0", }, }, - }); err != nil { + }, false); err != nil { t.Errorf("Shouldn't return error") } @@ -77,7 +81,7 @@ func TestCheckWithMatrix(t *testing.T) { LicenseSpdxID: "LGPL-2.0", }, }, - }); err == nil { + }, false); err == nil { t.Errorf("Should return error") } else if !strings.Contains(err.Error(), "Bar | LGPL-2.0") { t.Errorf("Should return error and contains dependency Bar, now is `%s`", err.Error()) @@ -96,7 +100,7 @@ func TestCheckWithMatrix(t *testing.T) { LicenseSpdxID: "Unknown", }, }, - }); err == nil { + }, false); err == nil { t.Errorf("Should return error") } else if !strings.Contains(err.Error(), "Bar | Unknown") { t.Errorf("Should return error and has dependency Bar, now is `%s`", err.Error()) @@ -109,7 +113,7 @@ func TestCheckWithMatrix(t *testing.T) { LicenseSpdxID: "Apache-2.0 OR MIT", }, }, - }); err != nil { + }, false); err != nil { t.Errorf("Shouldn't return error") } @@ -120,7 +124,7 @@ func TestCheckWithMatrix(t *testing.T) { LicenseSpdxID: "GPL-3.0 and GPL-3.0-or-later", }, }, - }); err == nil { + }, false); err == nil { t.Errorf("Should return error") } @@ -131,7 +135,7 @@ func TestCheckWithMatrix(t *testing.T) { LicenseSpdxID: "LGPL-2.1-only AND MIT AND BSD-2-Clause", }, }, - }); err == nil { + }, false); err == nil { t.Errorf("Should return error") } @@ -142,7 +146,29 @@ func TestCheckWithMatrix(t *testing.T) { LicenseSpdxID: "GPL-2.0-or-later WITH Bison-exception-2.2", }, }, - }); err == nil { + }, false); err == nil { t.Errorf("Should return error") } + + if err := deps.CheckWithMatrix("Apache-2.0", &TestMatrix, &deps.Report{ + Resolved: []*deps.Result{ + { + Dependency: "Foo", + LicenseSpdxID: "MPL-2.0", + }, + }, + }, false); err == nil { + t.Errorf("Should return error since compatibleWithConditions is turned off") + } + + if err := deps.CheckWithMatrix("Apache-2.0", &TestMatrix, &deps.Report{ + Resolved: []*deps.Result{ + { + Dependency: "Bar", + LicenseSpdxID: "MPL-2.0", + }, + }, + }, true); err != nil { + t.Errorf("Shouldn't return error") + } } From 1f9512cfdaeb7b6f1a6eff8b5f08f8d141d20bc4 Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Tue, 31 Oct 2023 10:09:06 +0800 Subject: [PATCH 07/11] fixed compatible-with-conditions Signed-off-by: Patrick Zheng --- commands/deps_check.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/deps_check.go b/commands/deps_check.go index d6c5284..bca43fd 100644 --- a/commands/deps_check.go +++ b/commands/deps_check.go @@ -29,7 +29,7 @@ import ( var compatibleWithConditions bool func init() { - DepsCheckCommand.PersistentFlags().BoolVarP(&compatibleWithConditions, "compatible-with-conditions", "cc", false, "if set, include compatible-with-conditions list in dependencies checking") + DepsCheckCommand.PersistentFlags().BoolVar(&compatibleWithConditions, "compatible-with-conditions", false, "if set, include compatible-with-conditions list in dependencies checking") } var DepsCheckCommand = &cobra.Command{ From b04be22d8993d63a303a36a2420f3c92148f0aeb Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Tue, 31 Oct 2023 17:20:55 +0800 Subject: [PATCH 08/11] added weak-compatible list to dependency check Signed-off-by: Patrick Zheng --- assets/compatibility/Apache-2.0.yaml | 20 ++++++++++++++++++-- commands/deps_check.go | 6 +++--- pkg/deps/check.go | 23 +++++++++++------------ pkg/deps/check_test.go | 2 +- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/assets/compatibility/Apache-2.0.yaml b/assets/compatibility/Apache-2.0.yaml index 118d8c8..4111a24 100644 --- a/assets/compatibility/Apache-2.0.yaml +++ b/assets/compatibility/Apache-2.0.yaml @@ -90,5 +90,21 @@ incompatible: - NPL-1.0 - NPL-1.1 -compatible-with-conditions: - - MPL-2.0 \ No newline at end of file +weak-compatible: + - CDDL-1.0 + - CDDL-1.1 + - CPL-1.0 + - EPL-1.0 + - EPL-2.0 + - ErlPL-1.1 + - IPA + - IPL-1.0 + - LicenseRef-scancode-ubuntu-font-1.0 + - LicenseRef-scancode-unrar + - MPL-1.0 + - MPL-1.1 + - MPL-2.0 + - OFL-1.1 + - OSL-3.0 + - Ruby + - SPL-1.0 \ No newline at end of file diff --git a/commands/deps_check.go b/commands/deps_check.go index bca43fd..b5025b5 100644 --- a/commands/deps_check.go +++ b/commands/deps_check.go @@ -26,10 +26,10 @@ import ( "github.com/apache/skywalking-eyes/pkg/deps" ) -var compatibleWithConditions bool +var weakCompatible bool func init() { - DepsCheckCommand.PersistentFlags().BoolVar(&compatibleWithConditions, "compatible-with-conditions", false, "if set, include compatible-with-conditions list in dependencies checking") + DepsCheckCommand.PersistentFlags().BoolVarP(&weakCompatible, "weak-compatible", "w", false, "if set, include the weak-compatible list in dependencies checking") } var DepsCheckCommand = &cobra.Command{ @@ -40,7 +40,7 @@ var DepsCheckCommand = &cobra.Command{ var errors []error configDeps := Config.Dependencies() for _, header := range Config.Headers() { - if err := deps.Check(header.License.SpdxID, configDeps, compatibleWithConditions); err != nil { + if err := deps.Check(header.License.SpdxID, configDeps, weakCompatible); err != nil { errors = append(errors, err) } } diff --git a/pkg/deps/check.go b/pkg/deps/check.go index 6dd97c6..2dd1aba 100644 --- a/pkg/deps/check.go +++ b/pkg/deps/check.go @@ -30,9 +30,9 @@ import ( ) type CompatibilityMatrix struct { - Compatible []string `yaml:"compatible"` - Incompatible []string `yaml:"incompatible"` - CompatibleWithConditions []string `yaml:"compatible-with-conditions"` + Compatible []string `yaml:"compatible"` + Incompatible []string `yaml:"incompatible"` + WeakCompatible []string `yaml:"weak-compatible"` } var matrices = make(map[string]CompatibilityMatrix) @@ -64,7 +64,7 @@ func init() { } } -func Check(mainLicenseSpdxID string, config *ConfigDeps, compatibleWithConditions bool) error { +func Check(mainLicenseSpdxID string, config *ConfigDeps, weakCompatible bool) error { matrix := matrices[mainLicenseSpdxID] report := Report{} @@ -72,7 +72,7 @@ func Check(mainLicenseSpdxID string, config *ConfigDeps, compatibleWithCondition return nil } - return CheckWithMatrix(mainLicenseSpdxID, &matrix, &report, compatibleWithConditions) + return CheckWithMatrix(mainLicenseSpdxID, &matrix, &report, weakCompatible) } func compare(list []string, spdxID string) bool { @@ -100,17 +100,16 @@ func compareAny(spdxIDs []string, compare func(spdxID string) bool) bool { return false } -func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, report *Report, compatibleWithConditions bool) error { +func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, report *Report, weakCompatible bool) error { var incompatibleResults []*Result var unknownResults []*Result - fmt.Println("compatibleWithConditions:", compatibleWithConditions) for _, result := range append(report.Resolved, report.Skipped...) { operator, spdxIDs := parseLicenseExpression(result.LicenseSpdxID) switch operator { case LicenseOperatorAND: if compareAll(spdxIDs, func(spdxID string) bool { - if compatibleWithConditions { - return compare(matrix.Compatible, spdxID) || compare(matrix.CompatibleWithConditions, spdxID) + if weakCompatible { + return compare(matrix.Compatible, spdxID) || compare(matrix.WeakCompatible, spdxID) } return compare(matrix.Compatible, spdxID) }) { @@ -124,8 +123,8 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo case LicenseOperatorOR: if compareAny(spdxIDs, func(spdxID string) bool { - if compatibleWithConditions { - return compare(matrix.Compatible, spdxID) || compare(matrix.CompatibleWithConditions, spdxID) + if weakCompatible { + return compare(matrix.Compatible, spdxID) || compare(matrix.WeakCompatible, spdxID) } return compare(matrix.Compatible, spdxID) }) { @@ -141,7 +140,7 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo if compatible := compare(matrix.Compatible, spdxIDs[0]); compatible { continue } - if compatibleWithConditions && compare(matrix.CompatibleWithConditions, spdxIDs[0]) { + if weakCompatible && compare(matrix.WeakCompatible, spdxIDs[0]) { continue } if incompatible := compare(matrix.Incompatible, spdxIDs[0]); incompatible { diff --git a/pkg/deps/check_test.go b/pkg/deps/check_test.go index b7025db..5f63a86 100644 --- a/pkg/deps/check_test.go +++ b/pkg/deps/check_test.go @@ -53,7 +53,7 @@ var TestMatrix = deps.CompatibilityMatrix{ "GPL-2.0-only", "GPL-2.0-or-later", }, - CompatibleWithConditions: []string{ + WeakCompatible: []string{ "MPL-2.0", }, } From dec847871924a4364ddc46e6818f01a6e812350b Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Tue, 31 Oct 2023 17:35:37 +0800 Subject: [PATCH 09/11] clean up Signed-off-by: Patrick Zheng --- pkg/deps/check_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/deps/check_test.go b/pkg/deps/check_test.go index 5f63a86..2799991 100644 --- a/pkg/deps/check_test.go +++ b/pkg/deps/check_test.go @@ -158,7 +158,7 @@ func TestCheckWithMatrix(t *testing.T) { }, }, }, false); err == nil { - t.Errorf("Should return error since compatibleWithConditions is turned off") + t.Errorf("Should return error since weak-compatible is turned off") } if err := deps.CheckWithMatrix("Apache-2.0", &TestMatrix, &deps.Report{ From 364b52e79c33638e3b0ff8edefd51c741e5f2c3d Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Wed, 1 Nov 2023 10:17:39 +0800 Subject: [PATCH 10/11] fixing lint Signed-off-by: Patrick Zheng --- commands/deps_check.go | 2 +- pkg/deps/check.go | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/commands/deps_check.go b/commands/deps_check.go index b5025b5..9b2c90b 100644 --- a/commands/deps_check.go +++ b/commands/deps_check.go @@ -29,7 +29,7 @@ import ( var weakCompatible bool func init() { - DepsCheckCommand.PersistentFlags().BoolVarP(&weakCompatible, "weak-compatible", "w", false, "if set, include the weak-compatible list in dependencies checking") + DepsCheckCommand.PersistentFlags().BoolVarP(&weakCompatible, "weak-compatible", "w", false, "if set to true, treat the weak-compatible licenses as compatible in dependencies check. Note: when set to true, make sure to manually confirm that weak-compatible licenses are used under the required conditions.") } var DepsCheckCommand = &cobra.Command{ diff --git a/pkg/deps/check.go b/pkg/deps/check.go index 2dd1aba..04e8301 100644 --- a/pkg/deps/check.go +++ b/pkg/deps/check.go @@ -100,6 +100,13 @@ func compareAny(spdxIDs []string, compare func(spdxID string) bool) bool { return false } +func compareCompatible(matrix *CompatibilityMatrix, spdxID string, weakCompatible bool) bool { + if weakCompatible { + return compare(matrix.Compatible, spdxID) || compare(matrix.WeakCompatible, spdxID) + } + return compare(matrix.Compatible, spdxID) +} + func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, report *Report, weakCompatible bool) error { var incompatibleResults []*Result var unknownResults []*Result @@ -108,10 +115,7 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo switch operator { case LicenseOperatorAND: if compareAll(spdxIDs, func(spdxID string) bool { - if weakCompatible { - return compare(matrix.Compatible, spdxID) || compare(matrix.WeakCompatible, spdxID) - } - return compare(matrix.Compatible, spdxID) + return compareCompatible(matrix, spdxID, weakCompatible) }) { continue } @@ -123,10 +127,7 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo case LicenseOperatorOR: if compareAny(spdxIDs, func(spdxID string) bool { - if weakCompatible { - return compare(matrix.Compatible, spdxID) || compare(matrix.WeakCompatible, spdxID) - } - return compare(matrix.Compatible, spdxID) + return compareCompatible(matrix, spdxID, weakCompatible) }) { continue } From 820e28e4560eda386e5800f16ceda4ccb976af41 Mon Sep 17 00:00:00 2001 From: Patrick Zheng Date: Wed, 1 Nov 2023 10:56:15 +0800 Subject: [PATCH 11/11] fixed CI Signed-off-by: Patrick Zheng --- commands/deps_check.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/deps_check.go b/commands/deps_check.go index 9b2c90b..87aab07 100644 --- a/commands/deps_check.go +++ b/commands/deps_check.go @@ -29,7 +29,10 @@ import ( var weakCompatible bool func init() { - DepsCheckCommand.PersistentFlags().BoolVarP(&weakCompatible, "weak-compatible", "w", false, "if set to true, treat the weak-compatible licenses as compatible in dependencies check. Note: when set to true, make sure to manually confirm that weak-compatible licenses are used under the required conditions.") + DepsCheckCommand.PersistentFlags().BoolVarP(&weakCompatible, "weak-compatible", "w", false, + "if set to true, treat the weak-compatible licenses as compatible in dependencies check. "+ + "Note: when set to true, make sure to manually confirm that weak-compatible licenses "+ + "are used under the required conditions.") } var DepsCheckCommand = &cobra.Command{