Skip to content

Commit

Permalink
Reduce cycolmatic complexity (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo authored Oct 20, 2024
1 parent f144b13 commit 8bad7d1
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class RunOrder {
/**
* Returns the specified RunOrder
*
* @param values The runorder string value
* @return An array of RunOrder objects, never null
* @param values the runorder string value
* @return an array of RunOrder objects, never null
*/
public static RunOrder[] valueOfMulti(String values) {
List<RunOrder> result = new ArrayList<>();
Expand Down Expand Up @@ -78,14 +78,13 @@ public static RunOrder valueOf(String name) {
}

private static String createMessageForMissingRunOrder(String name) {
RunOrder[] runOrders = values();
RunOrder[] runOrders = values(); // guaranteed non-empty
StringBuilder message = new StringBuilder("There's no RunOrder with the name ");
message.append(name);
message.append(". Use one of the following RunOrders: ");
for (int i = 0; i < runOrders.length; i++) {
if (i != 0) {
message.append(", ");
}
message.append(runOrders[0]);
for (int i = 1; i < runOrders.length; i++) {
message.append(", ");
message.append(runOrders[i]);
}
message.append('.');
Expand All @@ -98,12 +97,11 @@ private static RunOrder[] values() {

public static String asString(RunOrder[] runOrder) {
StringBuilder stringBuffer = new StringBuilder();
for (int i = 0; i < runOrder.length; i++) {
for (int i = 0; i < runOrder.length - 1; i++) {
stringBuffer.append(runOrder[i].name);
if (i < (runOrder.length - 1)) {
stringBuffer.append(",");
}
stringBuffer.append(",");
}
stringBuffer.append(runOrder[runOrder.length - 1].name);
return stringBuffer.toString();
}

Expand Down

0 comments on commit 8bad7d1

Please sign in to comment.