Skip to content

POC/Draft: Add dev/deps visualization tool

Administrator requested to merge import-smells into master

Created by: efritz

Our imports can be very confusing! I've made a tool to try to visualize what package import other packages. After a cursory glance at things like godepgraph, I didn't find something that adequately visualizes what I'm trying to look for.

The tool committed here is a very very rough draft a package-import visualizer that:

  • visualizes packages only within the given target (e.g. will only show sourcegraph packages, not vendors or stdlib)
  • shows package nesting via subgraph organization
  • can optionally ignore classes of edges (ignore imports of descendants)

It can be run via:

go run ./dev/deps/main.go > sample.dot && dot -Tsvg sample.dot > sample.svg

Currently there are no flags and just package-declared globals.

Here is the output for the enterprise/cmd package:

c

The same package ignoring imports of packages that are descendants of siblings (which should never indicate a smell):

b

The same package also ignoring imports of descendant packages (which shoudl also never indicate a smell):

a

From this, we can see that enterprise/cmd/repo-updater imports the db package from enterprise/cmd/frontend, which I think indicates some incorrect organization (the OSS packages have a symmetric smell).

Looking for suggestions on how to improve this tool to catch these kind of high-level tech debt issues / organizational yuckies.

I plan to extend this tool a bit to visualize different things such as "show all dependents of this particular package up to depth N"

Looking for suggestions on other use cases and suggestions for output rendering (if there's a dot wizard in the company please show yourself).

Merge request reports

Loading