Open ekner opened 2 years ago
Plan:
In the if-statement if (transformRule == null || transformRule.length() == 0 || prefixMatcher.group(numOfGroups) == null) {
there are two clauses which are quite similar. The first handles the case when there is no transform rule and the second when there is one. The contents in these clauses can be moved to their own functions. The first function must take the following parameters: isViableOriginalNumber, number, prefixMatcher, generalDesc, carrierCode, numOfGroups
. The second one must take the same parameters and one additional: transformRule
. Those are quite a lot, but there is also one upside with this refactoring: There are no values that are changed here that must be propagated to the calling function. This means the code can simply by copied to their respective functions without any changes.
Cyclomatic complexity after refactor: 7 (56% decrease from 16)
Current cyclomatic complexity: 16