Skip to content

Commit

Permalink
feat: restructure how license violations are printed to be more consi…
Browse files Browse the repository at this point in the history
…stent
  • Loading branch information
G-Rath committed May 24, 2024
1 parent b419ea5 commit d5c8f4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
32 changes: 21 additions & 11 deletions internal/output/__snapshots__/vertical_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@ path/to/my/third/lockfile: found 2 packages with issues
path/to/my/first/lockfile: found 1 package with issues
no known vulnerabilities found

mine1@1.2.3 is using an incompatible license: MIT
license violations found:
mine1@1.2.3 (MIT)

1 license violation found in path/to/my/first/lockfile

path/to/my/second/lockfile: found 2 packages with issues
no known vulnerabilities found

mine2@3.2.5 is using an incompatible license: Apache-2.0
license violations found:
mine2@3.2.5 (Apache-2.0)

1 license violation found in path/to/my/second/lockfile

path/to/my/third/lockfile: found 2 packages with issues
no known vulnerabilities found

mine1@1.2.3 is using an incompatible license: MIT
license violations found:
mine1@1.2.3 (MIT)

1 license violation found in path/to/my/third/lockfile

Expand Down Expand Up @@ -75,7 +78,8 @@ path/to/my/first/lockfile: found 1 package with issues
path/to/my/first/lockfile: found 1 package with issues
no known vulnerabilities found

mine1@1.2.3 is using incompatible licenses: MIT, Apache-2.0
license violations found:
mine1@1.2.3 (MIT, Apache-2.0)

2 license violations found in path/to/my/first/lockfile

Expand All @@ -85,7 +89,8 @@ path/to/my/first/lockfile: found 1 package with issues
path/to/my/first/lockfile: found 1 package with issues
no known vulnerabilities found

mine1@1.2.3 is using an incompatible license: MIT
license violations found:
mine1@1.2.3 (MIT)

1 license violation found in path/to/my/first/lockfile

Expand All @@ -95,7 +100,8 @@ path/to/my/first/lockfile: found 1 package with issues
path/to/my/first/lockfile: found 1 package with issues
no known vulnerabilities found

mine1@1.2.3 is using an incompatible license: MIT
license violations found:
mine1@1.2.3 (MIT)

1 license violation found in path/to/my/first/lockfile

Expand All @@ -113,7 +119,8 @@ path/to/my/first/lockfile: found 1 package with issues

1 known vulnerability found in path/to/my/first/lockfile

mine1@1.2.3 is using an incompatible license: MIT
license violations found:
mine1@1.2.3 (MIT)

1 license violation found in path/to/my/first/lockfile

Expand All @@ -132,8 +139,9 @@ path/to/my/third/lockfile: found 2 packages with issues

1 known vulnerability found in path/to/my/third/lockfile

mine1@1.3.5 is using an incompatible license: MIT
mine1@1.2.3 is using an incompatible license: Apache-2.0
license violations found:
mine1@1.3.5 (MIT)
mine1@1.2.3 (Apache-2.0)

2 license violations found in path/to/my/third/lockfile

Expand All @@ -147,7 +155,8 @@ path/to/my/first/lockfile: found 1 package with issues

1 known vulnerability found in path/to/my/first/lockfile

mine1@1.2.3 is using an incompatible license: MIT
license violations found:
mine1@1.2.3 (MIT)

1 license violation found in path/to/my/first/lockfile

Expand All @@ -165,7 +174,8 @@ path/to/my/first/lockfile: found 1 package with issues
path/to/my/second/lockfile: found 1 package with issues
no known vulnerabilities found

mine2@5.9.0 is using an incompatible license: MIT
license violations found:
mine2@5.9.0 (MIT)

1 license violation found in path/to/my/second/lockfile

Expand Down
10 changes: 3 additions & 7 deletions internal/output/vertical.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func PrintVerticalResults(vulnResult *models.VulnerabilityResults, outputWriter
printVerticalLicenseViolations(result, outputWriter)
}

if i < len(vulnResult.Results) - 1 {
if i < len(vulnResult.Results)-1 {
fmt.Fprintln(outputWriter)
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ func printVerticalLicenseViolations(result models.PackageSource, out io.Writer)
return
}

fmt.Fprintln(out)
fmt.Fprintf(out, "\n %s\n", color.RedString("license violations found:"))

for _, pkg := range result.Packages {
if len(pkg.LicenseViolations) == 0 {
Expand All @@ -106,12 +106,8 @@ func printVerticalLicenseViolations(result models.PackageSource, out io.Writer)
}

fmt.Fprintf(out,
" %s %s %s\n",
" %s (%s)\n",
color.YellowString("%s@%s", pkg.Package.Name, pkg.Package.Version),
color.RedString(Form(len(violations),
"is using an incompatible license:",
"is using incompatible licenses:",
)),
color.CyanString(strings.Join(violations, ", ")),
)
}
Expand Down

0 comments on commit d5c8f4d

Please sign in to comment.