Class PackageRule
-
- All Implemented Interfaces:
public class PackageRule extends Rule
A Rule to check a single Package.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classPackageRule.LicenseRule
-
Field Summary
Fields Modifier and Type Field Description private final PackageuncuratedPkgprivate final Stringdescriptionprivate final CuratedPackagepkgprivate final ResolvedLicenseInforesolvedLicenseInfoprivate final List<RuleMatcher>matchersprivate final List<RuleViolation>violationsprivate final RuleSetruleSetprivate final Stringname
-
Constructor Summary
Constructors Constructor Description PackageRule(RuleSet ruleSet, String name, CuratedPackage pkg, ResolvedLicenseInfo resolvedLicenseInfo)
-
Method Summary
Modifier and Type Method Description final PackagegetUncuratedPkg()StringgetDescription()Return a human-readable description of this rule. final CuratedPackagegetPkg()The CuratedPackage to check. final ResolvedLicenseInfogetResolvedLicenseInfo()The resolved license info for the Package. StringissueSource()Return a string to be used as Issue. UnitrunInternal()Can be overridden to implement custom behavior, executed if a rule matches. final RuleMatcherhasVulnerability()A RuleMatcher that checks whether any vulnerability was found for the package. final RuleMatcherhasVulnerability(Float scoreThreshold, String scoringSystem)A RuleMatcher that checks whether any vulnerability for the package has a reference with a score that equals or is greater than scoreThreshold according to the scoringSystem. final RuleMatcherhasLicense()A RuleMatcher that checks if the package has any concluded, declared, or detected license. final RuleMatcherisExcluded()A RuleMatcher that checks if the package is excluded. final RuleMatcherisFromOrg(String names)A RuleMatcher that checks if the identifier of the package belongs to one of the provided organization names. final RuleMatcherisMetadataOnly()A RuleMatcher that checks whether the package is metadata only. final RuleMatcherisProject()A RuleMatcher that checks if the package was created from a Project. final RuleMatcherisType(String type)A RuleMatcher that checks if the identifier type of the package equals type. final UnitlicenseRule(String name, LicenseView licenseView, Function1<PackageRule.LicenseRule, Unit> block)A DSL function to configure a LicenseRule and add it to this rule. final Unitissue(Severity severity, String message, String howToFix)final Unithint(String message, String howToFix)Add a hint to the list of violations. final Unitwarning(String message, String howToFix)Add a warning to the list of violations. final Uniterror(String message, String howToFix)Add an error to the list of violations. -
Methods inherited from class org.ossreviewtoolkit.evaluator.Rule
error, evaluate, getMatchers, getName, getRuleSet, getViolations, hasLabel, hint, issue, require, warning -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getUncuratedPkg
final Package getUncuratedPkg()
-
getDescription
String getDescription()
Return a human-readable description of this rule.
-
getPkg
final CuratedPackage getPkg()
The CuratedPackage to check.
-
getResolvedLicenseInfo
final ResolvedLicenseInfo getResolvedLicenseInfo()
The resolved license info for the Package.
-
issueSource
String issueSource()
-
runInternal
Unit runInternal()
Can be overridden to implement custom behavior, executed if a rule matches.
-
hasVulnerability
final RuleMatcher hasVulnerability()
A RuleMatcher that checks whether any vulnerability was found for the package.
-
hasVulnerability
final RuleMatcher hasVulnerability(Float scoreThreshold, String scoringSystem)
A RuleMatcher that checks whether any vulnerability for the package has a reference with a score that equals or is greater than scoreThreshold according to the scoringSystem. If the reference provides no score but a severity, the threshold is mapped to a qualitative rating for comparison.
-
hasLicense
final RuleMatcher hasLicense()
A RuleMatcher that checks if the package has any concluded, declared, or detected license.
-
isExcluded
final RuleMatcher isExcluded()
A RuleMatcher that checks if the package is excluded.
-
isFromOrg
final RuleMatcher isFromOrg(String names)
A RuleMatcher that checks if the identifier of the package belongs to one of the provided organization names.
-
isMetadataOnly
final RuleMatcher isMetadataOnly()
A RuleMatcher that checks whether the package is metadata only.
-
isProject
final RuleMatcher isProject()
A RuleMatcher that checks if the package was created from a Project.
-
isType
final RuleMatcher isType(String type)
A RuleMatcher that checks if the identifier type of the package equals type.
-
licenseRule
final Unit licenseRule(String name, LicenseView licenseView, Function1<PackageRule.LicenseRule, Unit> block)
A DSL function to configure a LicenseRule and add it to this rule.
-
warning
final Unit warning(String message, String howToFix)
Add a warning to the list of violations.
-
-
-
-