Skip to content

CompareTemplateOutputHandler.compareText returns incorrect match token #305

@douglasclarke

Description

@douglasclarke

When reviewing the difference messages it appears in failures to match tokens that the message returned is for the token after the failed match.

String nextMatchToken = LicenseTextHelper.getTokenAt(matchTokens, matchTokenCounter++);

String nextMatchToken = LicenseTextHelper.getTokenAt(matchTokens, matchTokenCounter++);

This line gets the next token to match but also increments the counter so that on line 851 when the negative value of this is returned the result message identifies the token after the failed match.

alphabet = "a b c d e f g h i j k l m n o p q r s t u v w x y z" template = "a b c d e f g h i j k l m n o p q r s t u v w x y zebra was here"

When comparing these two the DifferenceDescription message appears as:
Normal text of license does not match starting at line #1 column #58 "was" when comparing to template text "a b c d e f g h i j k l m n o p q r s t u v w x y z"
If line 851 returned the index of the tokens that did not match taking into account any of the skipping I believe this would resolve. If time allows I will work on a PR with supporting test cases but wanted to raise the issue first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions