This repository has been archived by the owner on Apr 1, 2022. It is now read-only.
Use new shrink
function to filter sourceunit dependencies
#319
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
When converting our internal graph representation to a
SourceUnit
we, among other things, filter out unsupported dependency typesThis is problematic, because some analyzers (looking at you,
Gradle
) produce graphs containing onlySubprojectType
dependencies as direct. When we filter out those dependencies, we're left with a graph without any direct dependencies -- only deep dependencies and edges between them.shrink
is a new operation likefilter
that removes vertices, but incoming and outgoing edges from removed vertices are rewritten to preserve the overall graph structure. This means that, e.g., direct deps that are filtered out will have their successors marked as direct after ashrink
Unrelatedly, this refactors
Graphing
into its isomorphic representation,AdjacencyMap (Node a)
, wheredata Node a = Root | Node a
. This gains us much more code reuse in general, and reduces the surface area for incorrectly implementingGraphing
operations. In particular, it was non-trivial to correctly implementshrink
otherwise. I also refactor the operations ofGraphing
to more-closely mirror those ofAdjacencyMap
Acceptance criteria
shrink
is semantically sound for multi-node removal, rewiring several incoming/outgoing edges, and rewriting "direct" relationshipsTesting plan
SourceUnit.Build.Imports
array is emptySourceUnit.Build.Imports
array is non-emptyshrink
/shrinkSingle
Risks
shrink
needs to be semantically sound, because we run it on every SourceUnit we generate in the CLI.References
ZD3001 / ZD3006
docs/
.Changelog.md
if this change is externally facing. If this PR did not mark a release, I added my changes into an# Unreleased
section at the top.