Skip to content
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

Refactor nonOptionalTextToPatterns #222

Closed
goneall opened this issue Dec 13, 2023 · 2 comments
Closed

Refactor nonOptionalTextToPatterns #222

goneall opened this issue Dec 13, 2023 · 2 comments

Comments

@goneall
Copy link
Member

goneall commented Dec 13, 2023

After PR #221, the method nonOptionalTextToPatterns in LicenseCompareHelper has a complexity of 89 which is far to high.

I wasn't able to come up with a clean way to refactor the method into several static methods.

There are a couple alternative approaches:

  • Create a separate non-static class to parse the license templates and create the patterns
  • Change the FilterTemplateOutputHandler to output the actual regex for the license - e.g. construct the regex as the template is being filtered and create 2 methods getStartRegex(int numWords) and getEndRegex(int numWords)
@pmonks
Copy link
Collaborator

pmonks commented Dec 13, 2023

The first option (separate class dedicated to converting license templates and/or fragments of license templates into regexes) seems like a good option to me. It might be useful to someone independent of the LicenseCompareHelper, and is probably easier to test that way too.

@goneall
Copy link
Member Author

goneall commented Dec 16, 2023

Fixed with PR #224

@goneall goneall closed this as completed Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants