Merge branch 'refactor/improve-orderPhases' into 'dev'

refactor: removed unnecessary else blocks in orderPhases

See merge request ics/sp/2025/n25b/pepperplus-ui!19
This commit was merged in pull request #19.
This commit is contained in:
2584433
2025-11-14 11:46:44 +00:00

View File

@@ -174,25 +174,22 @@ export function orderPhases(nodes: AppNode[],edges: Edge[]) : OrderedPhases {
if (nextPhaseNodes.length === 1 && nextNodes.length === 1) {
connections.set(currentPhase.id, nextPhaseNodes[0].id);
return nextPhase(phases.push(nextPhaseNodes[0] as PhaseNode) - 1, {phaseNodes: phases, connections: connections});
} else {
}
// handle erroneous states
if (nextNodes.length === 0) {
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" doesn't have any outgoing connections`);
} else {
}
if (nextNodes.length > 1) {
throw new Error(`| INVALID PROGRAM | the source handle of "${currentPhase.id}" connects to too many targets`);
} else {
}
if (nextNodes[0].type === "end") {
connections.set(currentPhase.id, "end");
// returns the final output of the function
return {phaseNodes: phases, connections: connections};
} else {
}
throw new Error(`| INVALID PROGRAM | the node "${nextNodes[0].id}" that "${currentPhase.id}" connects to is not a phase or end node`);
}
}
}
}
}
// initializes the Map describing the connections between phase nodes
// we need this Map to make sure we preserve this information,
// so we don't need to do checks on the entire set of edges in further stages of the reduction algorithm