deps

package
v0.0.0-...-527d7fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package deps runs dependency-structure analysis on the files changed in a diff. It relies on a language-supplied lang.ImportResolver to turn source files into the adjacency map the graph algorithms operate on.

graph.go contains the pure-math primitives: cycle detection, coupling, instability, SDP violation detection. deps.go wires them up to an ImportResolver and builds a report.Section. Splitting the two makes the graph algorithms reusable for any language without dragging the orchestration (module-path detection, section formatting) along.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Analyze

func Analyze(repoPath string, d *diff.Result, resolver lang.ImportResolver) (report.Section, error)

Analyze examines import changes in the diff, builds a dependency graph via the supplied ImportResolver, and reports cycles, coupling, instability, and SDP violations.

Types

type Cycle

type Cycle []string

Cycle represents a circular dependency chain.

func (Cycle) String

func (c Cycle) String() string

String formats the cycle as "a -> b -> c -> a" (closing back to the start). Used in report findings.

type Graph

type Graph struct {
	Edges      map[string]map[string]bool
	ModulePath string
}

Graph represents an internal package dependency graph. Nodes are package-level identifiers (typically the module path plus the package directory, e.g. "example.com/mod/internal/foo"). Edges point from importer to importee.

type PackageMetrics

type PackageMetrics struct {
	Package     string
	Afferent    int
	Efferent    int
	Instability float64
}

PackageMetrics holds coupling and instability metrics for a package. Afferent = how many other packages import this one ("fan-in"). Efferent = how many other packages this one imports ("fan-out"). Instability = Efferent / (Afferent + Efferent), range [0,1].

type SDPViolation

type SDPViolation struct {
	Package               string
	Dependency            string
	PackageInstability    float64
	DependencyInstability float64
}

SDPViolation represents a Stable Dependencies Principle violation: a package with low instability (stable) imports a package with higher instability (unstable).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL