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

Refactor nonOptionalTextToPatterns #222

Closed goneall closed 6 months ago

goneall commented 6 months ago

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:

pmonks commented 6 months ago

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 commented 6 months ago

Fixed with PR #224