Skip to content

Support NONE and NOASSERTION in license expressions #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,11 @@ private static AnyLicenseInfo parseSimpleLicenseToken(String token, IModelStore
}
}
return new ListedLicense(store, listedLicense.getObjectUri(), copyManager, true, SpdxConstantsV3.SPDX_LISTED_LICENSE_NAMESPACE);
} else {
} else if (SpdxConstantsCompatV2.NOASSERTION_VALUE.equals(token)) {
return new NoAssertionLicense();
} else if (SpdxConstantsCompatV2.NONE_VALUE.equals(token)) {
return new NoneLicense();
}else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}else {
} else {

// LicenseRef
String objectUri = customLicenseUriPrefix + token;
CustomLicense localLicense;
Expand Down Expand Up @@ -571,6 +575,10 @@ private static org.spdx.library.model.v2.license.AnyLicenseInfo parseSimpleLicen
}
return (org.spdx.library.model.v2.license.AnyLicenseInfo) org.spdx.library.model.v2.SpdxModelFactoryCompatV2.getModelObjectV2(store, SpdxConstantsCompatV2.LISTED_LICENSE_NAMESPACE_PREFIX,
licenseId.get(), SpdxConstantsCompatV2.CLASS_SPDX_LISTED_LICENSE, copyManager, true);
} else if (SpdxConstantsCompatV2.NOASSERTION_VALUE.equals(token)) {
return new SpdxNoAssertionLicense();
} else if (SpdxConstantsCompatV2.NONE_VALUE.equals(token)) {
return new SpdxNoneLicense();
} else {
// LicenseRef
Optional<String> caseSensitiveId = store.getCaseSensitiveId(documentUri, token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,13 @@ public void testExternalLicenseAddition() throws InvalidSPDXAnalysisException {
}
}

public void regressionMitWith() throws InvalidSPDXAnalysisException, InvalidLicenseStringException {
public void regressionMitWith() throws InvalidSPDXAnalysisException {
AnyLicenseInfo result = LicenseInfoFactory.parseSPDXLicenseString("MIT WITH Autoconf-exception-2.0");
assertEquals("MIT WITH Autoconf-exception-2.0",result.toString());
}

public void testParseNoAssertionAnds() throws InvalidSPDXAnalysisException {
AnyLicenseInfo result = LicenseInfoFactory.parseSPDXLicenseString("MIT AND NOASSERTION AND NONE");
assertEquals("(MIT AND NOASSERTION AND NONE)",result.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,13 @@ public void testExternalLicenseRef() throws InvalidSPDXAnalysisException {
assertEquals(externalExtractedId, ((ExternalExtractedLicenseInfo)result).toString());
}

public void regressionMitWith() throws InvalidSPDXAnalysisException, InvalidLicenseStringException {
public void regressionMitWith() throws InvalidSPDXAnalysisException {
AnyLicenseInfo result = LicenseInfoFactory.parseSPDXLicenseStringCompatV2("MIT WITH Autoconf-exception-2.0");
assertEquals("MIT WITH Autoconf-exception-2.0",result.toString());
}

public void testParseNoAssertionAnds() throws InvalidSPDXAnalysisException {
AnyLicenseInfo result = LicenseInfoFactory.parseSPDXLicenseStringCompatV2("MIT AND NOASSERTION AND NONE");
assertEquals("(MIT AND NOASSERTION AND NONE)",result.toString());
Comment on lines +235 to +236
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmonks This part of the code targets SPDX 2.x. So it has to be separately resolved.

}
}