In the dependency_graph.add_child_vertex the variable root is assigned:
root = !parent_names.delete(nil) { true }
This assignment does not makes sense to me.
| Test Case |
root |
![].delete(nil) { true } |
false |
![nil].delete(nil) { true } |
true |
!["a", "b"].delete(nil) { true } |
false |
!["a", "b", nil].delete(nil) { true } |
true |
![nil, "a", "b"].delete(nil) { true } |
true |
If the intent is to allow a root vertex to be created using the add_child_vertex method, the criteria is that the parent_names list is empty (or for some reason only contains nil values). In general, it seems like creating a root vertex in this method is undesirable and an exception should be thrown if the parent names list is empty. In any case, the current implementation is either incorrect or a comment should be added to clarify the intent.
In the
dependency_graph.add_child_vertexthe variablerootis assigned:This assignment does not makes sense to me.
root![].delete(nil) { true }![nil].delete(nil) { true }!["a", "b"].delete(nil) { true }!["a", "b", nil].delete(nil) { true }![nil, "a", "b"].delete(nil) { true }If the intent is to allow a root vertex to be created using the
add_child_vertexmethod, the criteria is that theparent_nameslist is empty (or for some reason only containsnilvalues). In general, it seems like creating a root vertex in this method is undesirable and an exception should be thrown if the parent names list is empty. In any case, the current implementation is either incorrect or a comment should be added to clarify the intent.