spdx / Spdx-Java-Library

Java library which implements the Java object model for SPDX and provides useful helper functions
Apache License 2.0
32 stars 33 forks source link

Column in DifferenceDescription returned by LicenseCompareHelper.isTextMatchingTemplate is not correct #243

Open sdheh opened 3 weeks ago

sdheh commented 3 weeks ago

LicenseCompareHelper.isTextMatchingTemplate has the following code

compareTemplateOutputHandler = new CompareTemplateOutputHandler(removeLineSeparators(removeCommentChars(compareText)));

The column returned if there is a difference in a line from which comment chars were removed is wrong because it refers to the transformed text.

Example:

String licenseText = "// a b";
String template = "a";
System.out.println(LicenseCompareHelper.isTextMatchingTemplate(template, licenseText).getDifferenceMessage());

returns Additional text found after the end of the expected license text starting at line #1 column #3 "b"

goneall commented 3 weeks ago

Thanks again @sdheh for the analysis.

Pull requests are welcome - otherwise I'll look into a fix after finishing the SPDX 3.0 upgrade work.