From 32430f926cd7c2f9db36393cf42926ab856d2696 Mon Sep 17 00:00:00 2001 From: Gary O'Neall Date: Tue, 2 Dec 2025 10:52:24 -0800 Subject: [PATCH] Don't require exact match on ignored warnings Signed-off-by: Gary O'Neall --- pom.xml | 6 +- .../LicenseRDFAGenerator.java | 57 +------------------ 2 files changed, 6 insertions(+), 57 deletions(-) diff --git a/pom.xml b/pom.xml index 14e22e2..9c98072 100644 --- a/pom.xml +++ b/pom.xml @@ -95,17 +95,17 @@ org.spdx spdx-rdf-store - 2.0.1 + 2.0.2 org.spdx java-spdx-library - 2.0.1 + 2.0.2 org.spdx spdx-v3jsonld-store - 1.0.1 + 1.0.2 diff --git a/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java b/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java index ab3d878..aeffdaf 100644 --- a/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java +++ b/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java @@ -262,7 +262,7 @@ public static void main(String[] args) { for (String warning:warnings) { boolean ignore = false; for (String ignoreStr:ignoredWarnings) { - if (warning.equalsIgnoreCase(ignoreStr)) { + if (warning.toLowerCase().startsWith(ignoreStr.toLowerCase())) { ignore = true; System.out.println("Ignoring warning '"+ignoreStr+"'"); break; @@ -597,7 +597,7 @@ private static Set writeLicenseList(String version, String releaseDate, licenseContainer.getV2ListedLicense().getLicenseText(), new HashMap<>()); for (Entry entry : addedLicIdTextMap.entrySet()) { - if (isLicenseTextEquivalent(entry.getValue(), licenseTokens)) { + if (LicenseTextHelper.isLicenseTextEquivalent(entry.getValue(), licenseTokens)) { warnings.add("Duplicates licenses: " + licenseContainer.getV2ListedLicense().getLicenseId() + ", " + entry.getKey()); } } @@ -624,7 +624,7 @@ private static Set writeLicenseList(String version, String releaseDate, String[] stdLicenseTokens = LicenseTextHelper.tokenizeLicenseText( ListedLicenses.getListedLicenses().getListedLicenseByIdCompatV2(stdLicenseId).getLicenseText(), new HashMap<>()); - if (isLicenseTextEquivalent(value, stdLicenseTokens)) { + if (LicenseTextHelper.isLicenseTextEquivalent(value, stdLicenseTokens)) { warnings.add("Duplicates licenses: " + key + ", " + stdLicenseId); } } @@ -643,57 +643,6 @@ private static Set writeLicenseList(String version, String releaseDate, } } - /** - * Returns true if two sets of license tokens is considered a match per - * the SPDX License matching guidelines documented at spdx.org (currently license matching guidelines) - * There are 2 unimplemented features - bullets/numbering is not considered and comments with no whitespace between text is not skipped - * @param licenseATokens normalized license tokens to compare - * @param licenseBTokens normalized license tokens to compare - * @return true if the license text is equivalent - */ - public static boolean isLicenseTextEquivalent(String[] licenseATokens, String[] licenseBTokens) { - //TODO: Move this to LicenseTextHelper and refactor - int bTokenCounter = 0; - int aTokenCounter = 0; - String nextAToken = LicenseTextHelper.getTokenAt(licenseATokens, aTokenCounter++); - String nextBToken = LicenseTextHelper.getTokenAt(licenseBTokens, bTokenCounter++); - while (nextAToken != null) { - if (nextBToken == null) { - // end of b stream - while (LicenseTextHelper.canSkip(nextAToken)) { - nextAToken = LicenseTextHelper.getTokenAt(licenseATokens, aTokenCounter++); - } - if (nextAToken != null) { - return false; // there is more stuff in the license text B, so not equal - } - } else if (LicenseTextHelper.tokensEquivalent(nextAToken, nextBToken)) { - // just move onto the next set of tokens - nextAToken = LicenseTextHelper.getTokenAt(licenseATokens, aTokenCounter++); - nextBToken = LicenseTextHelper.getTokenAt(licenseBTokens, bTokenCounter++); - } else { - // see if we can skip through some B tokens to find a match - while (LicenseTextHelper.canSkip(nextBToken)) { - nextBToken = LicenseTextHelper.getTokenAt(licenseBTokens, bTokenCounter++); - } - // just to be sure, skip forward on the A license - while (LicenseTextHelper.canSkip(nextAToken)) { - nextAToken = LicenseTextHelper.getTokenAt(licenseATokens, aTokenCounter++); - } - if (!LicenseTextHelper.tokensEquivalent(nextAToken, nextBToken)) { - return false; - } else { - nextAToken = LicenseTextHelper.getTokenAt(licenseATokens, aTokenCounter++); - nextBToken = LicenseTextHelper.getTokenAt(licenseBTokens, bTokenCounter++); - } - } - } - // need to make sure B is at the end - while (LicenseTextHelper.canSkip(nextBToken)) { - nextBToken = LicenseTextHelper.getTokenAt(licenseBTokens, bTokenCounter++); - } - return (nextBToken == null); - } - /** * Update license fields based on information from external metadata * @param licenseContainer