license

package
v0.59.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLicenseFile added in v0.25.0

func IsLicenseFile(filename string, overrideIgnore bool) (bool, float64)

IsLicenseFile checks if a file is a license file based on its name. Returns true/fals if the file is a license file, and the weight value associated with the match, as some matches are potentially more relevant. overrideIgnore skips over ignored paths to allow linters to correctly determine whether a path is a valid license file (e.g., to avoid listing each instance of a given LICENSE file as a duplicate)

func IsLicenseMatchConfident added in v0.24.0

func IsLicenseMatchConfident(dl License) bool

IsLicenseMatchConfident checks if the license match is confident enough to be considered valid.

func LicenseCheck

func LicenseCheck(ctx context.Context, cfg *config.Configuration, fsys fs.FS, deep bool) ([]License, []LicenseDiff, error)

LicenseCheck checks the licenses of the files in the given filesystem against the melange configuration. If deep is true, the entire tree is scanned. If deep is false, only the top directory and one level down are scanned.

Types

type Classifier

type Classifier interface {
	Identify(fsys fs.FS, licensePath string) ([]License, error)
}

Classifier can detect the type of a software license.

func NewClassifier

func NewClassifier() (Classifier, error)

NewClassifier creates a license classifier.

type License

type License struct {
	Name       string
	Type       golicenses.Type
	Confidence float64
	Source     string
	Overrides  string
}

License represents a software license, as detected by licenseclassifier.

func CollectLicenseInfo

func CollectLicenseInfo(ctx context.Context, fsys fs.FS, deep bool, cfg *config.Configuration) ([]License, error)

CollectLicenseInfo collects license information from the given filesystem. If deep is true, the entire tree is scanned. If deep is false, only the top directory and one level down are scanned.

type LicenseDiff

type LicenseDiff struct {
	Path     string
	Is       string
	Should   string
	Override string
	NewType  golicenses.Type
}

LicenseDiff represents a difference between the detected license and the expected license.

type LicenseFile

type LicenseFile struct {
	Name   string
	Path   string
	Weight float64
}

LicenseFile represents a license file, with its name, path, and relevance score.

func FindLicenseFiles

func FindLicenseFiles(fsys fs.FS, deep bool) ([]LicenseFile, error)

FindLicenseFiles returns a list of license files in a directory, sorted by their relevance score. If deep is true, the entire tree is scanned. If deep is false, only the top directory and one level down are scanned, returning the list of most likely licenses of the project itself (not vendored dependencies)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL