Skip to content

dev: Add depgraph utility

Warren Gifford requested to merge ef/depgraph into main

Created by: efritz

This adds an initial stab of a utility that analyzes our package dependencies (within sg/sg). Right now there's a binary with two subcommands:

  • trace {package}, which outputs a dot-formatted graph of that package's dependencies and dependents

Here is a trace of the enterprise/internal/codeintel/codeintel/stores/uploadstore package.

Screen Shot 2021-03-04 at 4 54 03 PM
  • lint {pass}, which runs one of three (opinionated) lints - right now it just prints diagnostics of warnings but we can't actually act on these yet

(NoDeadPackages)

All packages are:

  • a main package in cmd/, enterprise/cmd, dev (and some others with exceptions)
  • imported by another package

(NoReachingIntoCommands)

All package imports from outside cmd/X cannot reach into cmd/X.

(NoSingleDependents)

Any package that is imported by one user and is not a direct descendant, ancestor, or sibling is reported. We may need to tune this, but is meant to catch having something in shared code that isn't truly shared (or code that didn't make it all the way through a migration/rewrite).

Merge request reports

Loading