Skip to content

Unclear assignment of root in dependency_graph.add_child_vertex #172

@baron1405

Description

@baron1405

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions