Documentation ¶
Index ¶
- Constants
- Variables
- func FromOptions(licenseResults *IdentifierResults, enhancements Enhancements, ...) error
- func PassedStaticBlocksChecks(staticBlocks []string, nd normalizer.NormalizationData) bool
- type Block
- type Enhancements
- type IdentifierResults
- func Identify(options Options, licenseLibrary *licenses.LicenseLibrary, ...) (IdentifierResults, error)
- func IdentifyLicensesInDirectory(dirPath string, options Options, licenseLibrary *licenses.LicenseLibrary) (ret []IdentifierResults, err error)
- func IdentifyLicensesInFile(filePath string, options Options, licenseLibrary *licenses.LicenseLibrary) (IdentifierResults, error)
- func IdentifyLicensesInString(input string, options Options, licenseLibrary *licenses.LicenseLibrary) (IdentifierResults, error)
- type Match
- type Options
- type PatternMatch
Constants ¶
View Source
const AlphaNumericPattern = `/[a-zA-Z0-9]+/`
View Source
const CopyrightPattern = `` /* 139-byte string literal not displayed */
CopyrightPattern recognizes a block to be flagged as COPYRIGHT const COPYRIGHT_PATTERN = /^[^a-z0-9\n]*(?:All rights reserved\.?\s*)?(?:[ \t]*(?:Copyright|Copr\.?|\(c\)|[\xA9]))+\s+[^\n\r]+(?:[^a-z0-9]*All rights reserved\.?)?/gmi; The legacy pattern required one-or-more white-spaces AND one-or-more non-carriage-return chars after Copyright. Here we are minimally requiring just the one white-space (or more...).
Variables ¶
View Source
var ( CopyrightRegexp = regexp.MustCompile(CopyrightPattern) AlphaNumericRegexp = regexp.MustCompile(AlphaNumericPattern) )
View Source
var DefaultKeywordList = []string{
`public domain`,
`Affero`,
`[a-z]*gpl`,
`[a-z-]*commercial[a-z]*`,
`[a-z-]*licen[cs][a-z]*`,
}
View Source
var (
Logger = log.NewLogger(log.INFO)
)
Functions ¶
func FromOptions ¶
func FromOptions(licenseResults *IdentifierResults, enhancements Enhancements, licenseLibrary *licenses.LicenseLibrary) error
FromOptions adds enabled enhancements (in order)
func PassedStaticBlocksChecks ¶
func PassedStaticBlocksChecks(staticBlocks []string, nd normalizer.NormalizationData) bool
PassedStaticBlocksChecks verifies static blocks are present, if any
Types ¶
type Enhancements ¶
type IdentifierResults ¶
type IdentifierResults struct { Matches map[string][]Match Blocks []Block File string OriginalText string NormalizedText string Hash normalizer.Digest Notes string AcceptablePatternMatches []PatternMatch KeywordMatches []PatternMatch CopyRightStatements []PatternMatch }
func Identify ¶
func Identify(options Options, licenseLibrary *licenses.LicenseLibrary, normalizedData normalizer.NormalizationData) (IdentifierResults, error)
func IdentifyLicensesInDirectory ¶
func IdentifyLicensesInDirectory(dirPath string, options Options, licenseLibrary *licenses.LicenseLibrary) (ret []IdentifierResults, err error)
func IdentifyLicensesInFile ¶
func IdentifyLicensesInFile(filePath string, options Options, licenseLibrary *licenses.LicenseLibrary) (IdentifierResults, error)
func IdentifyLicensesInString ¶
func IdentifyLicensesInString(input string, options Options, licenseLibrary *licenses.LicenseLibrary) (IdentifierResults, error)
type Match ¶
func FindMatchingPatternInNormalizedData ¶
func FindMatchingPatternInNormalizedData(matchingPattern *licenses.PrimaryPatterns, normalized normalizer.NormalizationData) (results []Match, err error)
type Options ¶
type Options struct { ForceResult bool OmitBlocks bool Enhancements Enhancements }
type PatternMatch ¶
Click to show internal directories.
Click to hide internal directories.