fix: Multiple judgments in a workflow cannot be combined with one discriminator #4146#4151
fix: Multiple judgments in a workflow cannot be combined with one discriminator #4146#4151shaohuzhang1 merged 1 commit intov2from
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| ) | ||
| return !is_c && !isLoop(sourceNode.id, targetNode.id) | ||
| }, | ||
| }) |
There was a problem hiding this comment.
The code you provided looks mostly intact, but there are some improvements that can be made:
-
Function Documentation: Consider adding comments to explain the purpose of each function and its usage to improve readability.
-
Variable Naming: While 'sourceAnchor' and 'targetAnchor' suggest they might represent anchors associated with nodes, make sure these names accurately reflect their roles if needed.
-
Type Annotations: Using TypeScript or JavaScript's type system can help clarify the types of variables used, which could prevent errors during runtime.
-
Code Readability: The comparison
up_edge_list.find((up_edge) => ...)seems concise enough, but consider grouping related operations inside a helper function for better separation of concerns. -
Error Handling: If
is_ccould potentially beundefined, it'd be worth handling this case appropriately, perhaps returning a default value or throwing an error. -
Consistency: Ensure consistent spelling and formatting throughout the code for better maintainability.
Here's a slightly refined version of the code with these considerations:
class AppNodeModel extends HtmlResize.model {
constructor(graphModel) {
super();
this.graphModel = graphModel;
}
updateTargetConnection(targetNode, sourceNode) {
// Check for loop condition
const isLoop = (nodeA, nodeB) => {
let current = nodeB;
while (current !== undefined && current.id !== nodeA) {
current = this.graphModel.getNodeIncomingNode(current.id)[0] || null; // Simplified assumption
}
return current !== null;
};
// Return true if no cycle exists between targetNode and sourceNode
const isValidConnection = () => {
// Edge list approach
const upEdgeList = this.graphModel.getNodeIncomingEdge(targetNode.id);
// Filter edges based on anchor IDs
const edgeForAnchors = upEdgeList?.find(
(e) => e.targetAnchorId === targetAnchor.id && e.sourceAnchorId === sourceAnchor.id
);
// Return false if there's a direct path from source to target via anchor connections and not already connected
return !edgeForAnchors && !isLoop(sourceNode.id, targetNode.id);
};
// Additional logic here...
}
}
// Example usage
const appNodeModel = new AppNodeModel(new GraphModel());
appNodeModel.updateTargetConnection(nodeA, nodeB);This refactoring improves the clarity and functionality of your code while enhancing maintainability and readability.
fix: Multiple judgments in a workflow cannot be combined with one discriminator #4146