Open mcmire opened 4 months ago
To solve this, we will want to add logic which prevents a rule from getting executed more than once.
Past this, we have two possible routes:
Could we level-order traverse the rule tree with topological sort or depth-first-search?
This would prevent rules from being processed redundantly, it would satisfy the ALL dependencies must pass for each rule requirement, and wouldn't keep us from producing a flattened list as output. It's also probably the most theoretically efficient way to handle this if I'm understanding the problem correctly.
Edit: If we are able to iterate over the rule tree in alphabetic order, wouldn't we be able to create a dependency graph first that has a 1-1 relationship between each rule and each graph node?
@MajorLift Hmm, good thoughts. I think rather than using breadth- or depth-first iteration or even sorting the list alphabetically as I suggested, sorting the whole list of rules in the tree topologically first and then iterating over all of them as you suggested makes sense to me. Perhaps there is a way to prevent from flattening the list, but note that we don't need to keep the existing hierarchy as we plan on reorganizing the list into categories anyway: https://github.com/MetaMask/module-lint/issues/64
Say you have a rule that has two dependencies:
There are two problems with this:
The rule may get run more than once. This happens because the rule exists underneath two separate nodes in the rule tree: 1)
require-valid-package-manifest
and 2)require-changelog
. The rule tree does not look like this:but rather this:
require-valid-package-manifest
fails, butrequire-changelog
passes.(Possible solutions moved to a comment.)