Skip to content

Commit

Permalink
Merge pull request #40 from spdx/fix-duplicate-checks
Browse files Browse the repository at this point in the history
Ignore duplicate licenses and exceptions if they are deprecated
  • Loading branch information
goneall authored Nov 29, 2018
2 parents 1dbf872 + 43fd745 commit cae3471
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.spdx</groupId>
<artifactId>licenseListPublisher</artifactId>
<version>2.1.15</version>
<version>2.1.16</version>
<name>License List Publisher</name>
<description>Tool that generates license data found in the license-list-data repository from the license-list-XML source</description>
<licenses>
Expand Down
31 changes: 18 additions & 13 deletions src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,20 +368,23 @@ private static void writeExceptionList(String version, String releaseDate,
addExternalMetaData(nextException);
if (nextException.getLicenseExceptionId() != null && !nextException.getLicenseExceptionId().isEmpty()) {
// check for duplicate exceptions
Iterator<Entry<String, String>> addedExceptionIter = addedExceptionsMap.entrySet().iterator();
while (addedExceptionIter.hasNext()) {
Entry<String, String> entry = addedExceptionIter.next();
if (entry.getValue().trim().equals(nextException.getLicenseExceptionText().trim())) {
warnings.add("Duplicates exceptions: "+nextException.getLicenseExceptionId()+", "+entry.getKey());
if (!nextException.isDeprecated()) {
Iterator<Entry<String, String>> addedExceptionIter = addedExceptionsMap.entrySet().iterator();
while (addedExceptionIter.hasNext()) {
Entry<String, String> entry = addedExceptionIter.next();
if (entry.getValue().trim().equals(nextException.getLicenseExceptionText().trim())) {
warnings.add("Duplicates exceptions: "+nextException.getLicenseExceptionId()+", "+entry.getKey());
}
}
// check for a license ID with the same ID as the exception

addedExceptionsMap.put(nextException.getLicenseExceptionId(), nextException.getLicenseExceptionText());
}
// check for a license ID with the same ID as the exception
if (licenseIds.contains(nextException.getLicenseExceptionId())) {
warnings.add("A license ID exists with the same ID as an exception ID: "+nextException.getLicenseExceptionId());
}
checkText(nextException.getLicenseExceptionText(),
"License Exception Text for "+nextException.getLicenseExceptionId(), warnings);
addedExceptionsMap.put(nextException.getLicenseExceptionId(), nextException.getLicenseExceptionText());
for (ILicenseFormatWriter writer:writers) {
writer.writeException(nextException);
}
Expand Down Expand Up @@ -465,14 +468,16 @@ private static void writeLicenseList(String version, String releaseDate,
addExternalMetaData(license);
if (license.getLicenseId() != null && !license.getLicenseId().isEmpty()) {
// Check for duplicate licenses
Iterator<Entry<String, String>> addedLicenseTextIter = addedLicIdTextMap.entrySet().iterator();
while (addedLicenseTextIter.hasNext()) {
Entry<String, String> entry = addedLicenseTextIter.next();
if (LicenseCompareHelper.isLicenseTextEquivalent(entry.getValue(), license.getLicenseText())) {
warnings.add("Duplicates licenses: "+license.getLicenseId()+", "+entry.getKey());
if (!license.isDeprecated()) {
Iterator<Entry<String, String>> addedLicenseTextIter = addedLicIdTextMap.entrySet().iterator();
while (addedLicenseTextIter.hasNext()) {
Entry<String, String> entry = addedLicenseTextIter.next();
if (LicenseCompareHelper.isLicenseTextEquivalent(entry.getValue(), license.getLicenseText())) {
warnings.add("Duplicates licenses: "+license.getLicenseId()+", "+entry.getKey());
}
}
addedLicIdTextMap.put(license.getLicenseId(), license.getLicenseText());
}
addedLicIdTextMap.put(license.getLicenseId(), license.getLicenseText());
checkText(license.getLicenseText(), "License text for "+license.getLicenseId(), warnings);
for (ILicenseFormatWriter writer : writers) {
writer.writeLicense(license, license.isDeprecated(), license.getDeprecatedVersion());
Expand Down

0 comments on commit cae3471

Please # to comment.