Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some exclusions are incorrectly disabled when removingDuplicates #40

Closed
edwingamboa opened this issue Dec 5, 2018 · 2 comments
Closed
Assignees
Labels
bug [email protected] It should be implemented for version 2.x cubx.core.rte [email protected] It schould be implemented for cubx.core.rte 3.x version.

Comments

@edwingamboa
Copy link
Member

When removing a duplicated node, the DependencyTree class checks for invalid exclusions. In the _removeDuplicate method, it is expected that the duplicated nodes have the same children in the same order.

However, we have detected a case in which the same nodes have different subtrees. To reproduce this behaviour, this CRCInit config, can be used. One problem wiht this, is that some exclusions are disabled since the "excluded" property of two different nodes can be compared assuming that the nodes are the same, if this propery is different in both nodes, the exclusion of one of the nodes will be disabled.

I modify the code of the _removeDuplicate method (in chrome devtools) to log the exact differences in the console (it would apply from line 134):

// calculate the intersection of all excluded nodes. Only nodes that are excluded in both subtrees are removed
      descendantsOfDuplicated.forEach(function (node, idx) {
        var duplicate = descendantsOfDuplicate[idx];

        // the exclude on duplicate node is invalid because the same node is not marked as excluded in duplicated subtree
        if (!node.excluded && duplicate.excluded) {
        console.log('\n\nduplicated----------', duplicated.data.webpackageId, duplicated.data.artifactId,
          'duplicate---------', duplicateCopy.data.webpackageId, duplicateCopy.data.artifactId);

          console.log('descs of duplicated----------')
          descendantsOfDuplicated.forEach(function (node) {
            console.log(node.data.webpackageId, node.data.artifactId)
          })
          console.log('descs of duplicate----------')
          descendantsOfDuplicate.forEach(function (node) {
            console.log(node.data.webpackageId, node.data.artifactId)
            duplicate.excluded = false;
        })
        }

        // the exclude on duplicated node is invalid because the same node is not marked as excluded in duplicate subtree
        if (node.excluded && !duplicate.excluded) {
        console.log('\n\nduplicated----------', duplicated.data.webpackageId, duplicated.data.artifactId,
          'duplicate---------', duplicateCopy.data.webpackageId, duplicateCopy.data.artifactId);

          console.log('descs of duplicated----------')
          descendantsOfDuplicated.forEach(function (node) {
            console.log(node.data.webpackageId, node.data.artifactId)
          })
          console.log('descs of duplicate----------')
          descendantsOfDuplicate.forEach(function (node) {
            console.log(node.data.webpackageId, node.data.artifactId)
          })
        node.excluded = false;
      }
@edwingamboa edwingamboa added [email protected] It should be implemented for version 2.x cubx.core.rte [email protected] It schould be implemented for cubx.core.rte 3.x version. labels Dec 5, 2018
@edwingamboa edwingamboa added the bug label Dec 5, 2018
@edwingamboa
Copy link
Member Author

In cubx-dependency-resolver the issue was solved by traversing all nodes of a duplicate node since the sub-trees of two duplicated nodes can be different due to conflict resolution removals (See this). However, this means traversing node trees more times than before. A better solution would be great.

@pwrinc
Copy link
Member

pwrinc commented Jan 24, 2019

I think because we need to calculate the intersection of all descendants of the duplicates node and all descendants there is no better solution then traversing both (sub)trees and compare them against each other. So I would just migrate you solution from cubx-dependency-resolver to RTE

@pwrinc pwrinc closed this as completed Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [email protected] It should be implemented for version 2.x cubx.core.rte [email protected] It schould be implemented for cubx.core.rte 3.x version.
Projects
None yet
Development

No branches or pull requests

2 participants