Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions src/NuGetLicense/LicenseValidator/LicenseValidationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,15 @@ public record LicenseValidationResult(string PackageId,
public string? License { get; set; } = License;
public string? LicenseUrl { get; set; } = LicenseUrl;
public LicenseInformationOrigin LicenseInformationOrigin { get; set; } = LicenseInformationOrigin;

public override string ToString() => $"{nameof(LicenseValidationResult)} {{{nameof(PackageId)} = {PackageId}, " +
$"{nameof(PackageVersion)} = {PackageVersion}, " +
$"{nameof(PackageProjectUrl)} = {PackageProjectUrl}, " +
$"{nameof(Copyright)} = {Copyright}, " +
$"{nameof(Authors)} = {Authors}, " +
$"{nameof(ValidationErrors)} = [{string.Join(",", ValidationErrors)}], " +
$"{nameof(License)} = {License}, " +
$"{nameof(LicenseUrl)} = {LicenseUrl}, " +
$"{nameof(LicenseInformationOrigin)} = {LicenseInformationOrigin}}}";
}
}
6 changes: 3 additions & 3 deletions src/NuGetLicense/LicenseValidator/LicenseValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ private async Task ValidateLicenseByMetadataAsync(IPackageMetadata info,
}
case LicenseType.File:
{
string? matchedLicense = _fileLicenseMatcher.Match(info.LicenseMetadata.License);
SpdxExpression? licenseExpression = matchedLicense is null ? null : SpdxExpressionParser.Parse(matchedLicense, _ => true, _ => true);
string matchedLicense = _fileLicenseMatcher.Match(info.LicenseMetadata.License);
SpdxExpression? licenseExpression = string.IsNullOrEmpty(matchedLicense) ? null : SpdxExpressionParser.Parse(matchedLicense, _ => true, _ => true);
if (IsValidLicenseExpression(licenseExpression))
{
await StoreLicenseAsync(info.LicenseMetadata.License, info.Identity, token);
Expand All @@ -173,7 +173,7 @@ private async Task ValidateLicenseByMetadataAsync(IPackageMetadata info,
AddOrUpdateLicense(result,
info,
LicenseInformationOrigin.File,
new ValidationError("Cannot determine license from license file", context),
new ValidationError("Unable to determine license from the given license file", context),
info.LicenseMetadata.License);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/SPDXLicenseMatcher/FastLicenseMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public FastLicenseMatcher(IDictionary<string, ILicense> licenses)

_templateInstructions = builder.ToImmutable();
}
public string? Match(string licenseText) => string.Join(" OR ", FindMatchingLicenses(licenseText));
public string Match(string licenseText) => string.Join(" OR ", FindMatchingLicenses(licenseText));

public IEnumerable<string> FindMatchingLicenses(string licenseText)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SPDXLicenseMatcher/ILicenseMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace SPDXLicenseMatcher
{
public interface ILicenseMatcher
{
string? Match(string licenseText);
string Match(string licenseText);
}
}
2 changes: 1 addition & 1 deletion src/SPDXLicenseMatcher/LicenseMatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ namespace SPDXLicenseMatcher
/// </summary>
public class LicenseMatcher : ILicenseMatcher
{
public string? Match(string licenseText) => string.Join(" OR ", LicenseCompareHelper.GetMatchingLicenses(licenseText));
public string Match(string licenseText) => string.Join(" OR ", LicenseCompareHelper.GetMatchingLicenses(licenseText));
}
}
Loading
Loading