You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by ke...@apache.org on 2023/04/09 02:34:56 UTC

[skywalking-eyes] branch deps/check created (now 6c085cf)

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a change to branch deps/check
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git


      at 6c085cf  Dependencies check should report unknown licneses

This branch includes the following new commits:

     new 6c085cf  Dependencies check should report unknown licneses

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking-eyes] 01/01: Dependencies check should report unknown licneses

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch deps/check
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 6c085cfbd5f95bd58fc4e5ce0614948f9d67bae0
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Sun Apr 9 10:34:47 2023 +0800

    Dependencies check should report unknown licneses
---
 assets/compatibility/Apache-2.0.yaml |  1 +
 pkg/deps/check.go                    | 28 ++++++++++++++++++++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/assets/compatibility/Apache-2.0.yaml b/assets/compatibility/Apache-2.0.yaml
index 1814b40..752f871 100644
--- a/assets/compatibility/Apache-2.0.yaml
+++ b/assets/compatibility/Apache-2.0.yaml
@@ -43,6 +43,7 @@ compatible:
   - Unlicense.txt
   - HPND.txt
   - MulanPSL-2.0.txt
+  - MIT
 
 incompatible:
   - Unknown
diff --git a/pkg/deps/check.go b/pkg/deps/check.go
index 15bc546..92b491d 100644
--- a/pkg/deps/check.go
+++ b/pkg/deps/check.go
@@ -19,6 +19,7 @@ package deps
 
 import (
 	"fmt"
+	"math"
 	"path/filepath"
 	"strings"
 
@@ -75,6 +76,7 @@ func Check(mainLicenseSpdxID string, config *ConfigDeps) error {
 
 func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, report *Report) error {
 	var incompatibleResults []*Result
+	var unknownResults []*Result
 	for _, result := range append(report.Resolved, report.Skipped...) {
 		compare := func(list []string, spdxID string) bool {
 			for _, com := range list {
@@ -134,16 +136,34 @@ func CheckWithMatrix(mainLicenseSpdxID string, matrix *CompatibilityMatrix, repo
 			}
 			if incompatible := compare(matrix.Incompatible, spdxIDs[0]); incompatible {
 				incompatibleResults = append(incompatibleResults, result)
+				continue
 			}
+			unknownResults = append(unknownResults, result)
 		}
 	}
 
-	if len(incompatibleResults) > 0 {
-		str := ""
+	if len(incompatibleResults) > 0 || len(unknownResults) > 0 {
+		dWidth, lWidth := .0, .0
 		for _, r := range incompatibleResults {
-			str += fmt.Sprintf("\nLicense: %v Dependency: %v", r.LicenseSpdxID, r.Dependency)
+			dWidth = math.Max(float64(len(r.Dependency)), dWidth)
+			lWidth = math.Max(float64(len(r.LicenseSpdxID)), lWidth)
+		}
+		for _, r := range unknownResults {
+			dWidth = math.Max(float64(len(r.Dependency)), dWidth)
+			lWidth = math.Max(float64(len(r.LicenseSpdxID)), lWidth)
 		}
-		return fmt.Errorf("the following licenses are incompatible with the main license: %v %v", mainLicenseSpdxID, str)
+
+		rowTemplate := fmt.Sprintf("%%-%dv | %%%dv\n", int(dWidth), int(lWidth))
+		s := fmt.Sprintf(rowTemplate, "Dependency", "License")
+		s += fmt.Sprintf(rowTemplate, strings.Repeat("-", int(dWidth)), strings.Repeat("-", int(lWidth)))
+		for _, r := range incompatibleResults {
+			s += fmt.Sprintf(rowTemplate, r.Dependency, r.LicenseSpdxID)
+		}
+		for _, r := range unknownResults {
+			s += fmt.Sprintf(rowTemplate, r.Dependency, r.LicenseSpdxID)
+		}
+
+		return fmt.Errorf("the following licenses are unknown or incompatible with the main license, please check manually: %v\n%v", mainLicenseSpdxID, s)
 	}
 
 	return nil