conformance

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package conformance verifies code against the dependency rules of a ratified development method, through the language's own tool. GTT has no import analyser of its own: an adapter turns the neutral rules the Bootstrap declares (method.rules) into that tool's configuration, runs it and maps what it reports back to the rules. It decides nothing: a violation is a conflict to report, never something to correct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(root string, rows []Row) map[string]any

Config is the dependency-cruiser configuration for the rows: one forbidden rule per (row, module glob, forbidden glob). A forbidden glob equal to the module glob means "another one of the same kind" (a slice must not depend on another slice), and so does one below it (a context must not reach into another context's internals): the module itself is excluded through a group match.

func DeptracConfig added in v1.8.0

func DeptracConfig(root string, rows []Row, paths []string) (cfg string, forbidden map[string]string, layers map[string]string)

DeptracConfig is the deptrac configuration for the rows. Deptrac's ruleset lists what a layer MAY depend on, so every concrete module is a layer and each layer may depend on every other layer except those the rules forbid it. forbidden maps "layer>layer" back to the rule.

func Expand added in v1.8.0

func Expand(root, glob string, suffixes ...string) []string

Expand lists the project's folders a glob names, relative to root. A glob without wildcards names itself, when it exists (or, with a suffix such as ".py", when that file exists). Hidden folders, `__*__`, node_modules and vendor are never part of a wildcard.

func LinterConfig added in v1.8.0

func LinterConfig(root string, rows []Row) (cfg string, src bool, contracts int)

LinterConfig is the import-linter configuration for the rows: one forbidden contract per concrete module and what it must not import, direct imports only (as for the other languages). The contract is named after the rule, so the report maps back to it. src reports a src layout.

func Paths

func Paths(cell string) []string

Paths splits a cell into path globs: comma separated, annotations such as "(another slice)" dropped, "-" and empty entries skipped.

func Pattern

func Pattern(glob string, capture bool) string

Pattern turns a path glob into an anchored regular expression over paths relative to the project root. `**` is any depth, `*` one path segment. With capture, each `*` is a group, so a rule can refer to "the same one".

func Roots

func Roots(rows []Row) []string

Roots are the top-level folders the rows name, which is what the tool scans.

func Sibling

func Sibling(glob string) string

Sibling is the pattern of "the same one" as the captured from-module: `src/features/*` -> `^src/features/$1(/|$)`.

func Supported

func Supported() []string

Supported lists the languages that have an adapter.

Types

type Adapter

type Adapter interface {
	ID() string
	Language() string
	// Applies says whether the project is written in this adapter's language.
	Applies(root string) bool
	// Tool locates the language's tool; "" means it is not installed.
	Tool(root string, runner ports.Runner) string
	// Install says how to install the tool, for the human to run.
	Install() string
	// Check runs the tool. A non-nil error means the result could not be
	// determined, never that the code is fine.
	Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)
}

Adapter verifies the rows for one language.

func Adapters

func Adapters() []Adapter

Adapters is the registry, in the order they are tried. Adding a language is adding an adapter here. JavaScript/TypeScript comes last: a package.json is often only the front-end or tooling of a project written in another language, while go.mod, pom.xml, composer.json or pyproject.toml are not. .NET has no adapter: its architecture test tools are libraries, not CLIs.

func For

func For(root string) Adapter

For returns the adapter for the project's language, or nil.

type Conflict

type Conflict struct {
	Rule string `json:"rule"`
	From string `json:"from"`
	To   string `json:"to"`
}

Conflict is one forbidden dependency found in the code.

type DependencyCruiser

type DependencyCruiser struct{}

DependencyCruiser is the adapter for JavaScript and TypeScript: https://github.com/sverweij/dependency-cruiser. It uses the project's own installation (node_modules/.bin) or one on the PATH, and never downloads it.

func (DependencyCruiser) Applies

func (DependencyCruiser) Applies(root string) bool

func (DependencyCruiser) Check

func (d DependencyCruiser) Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)

func (DependencyCruiser) ID

func (DependencyCruiser) Install added in v1.8.0

func (DependencyCruiser) Install() string

func (DependencyCruiser) Language

func (DependencyCruiser) Language() string

func (DependencyCruiser) Tool

func (DependencyCruiser) Tool(root string, runner ports.Runner) string

type Deptrac added in v1.8.0

type Deptrac struct{}

Deptrac is the adapter for PHP: https://github.com/deptrac/deptrac. It uses the project's own installation (vendor/bin) or one on the PATH, and never installs it.

func (Deptrac) Applies added in v1.8.0

func (Deptrac) Applies(root string) bool

func (Deptrac) Check added in v1.8.0

func (d Deptrac) Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)

func (Deptrac) ID added in v1.8.0

func (Deptrac) ID() string

func (Deptrac) Install added in v1.8.0

func (Deptrac) Install() string

func (Deptrac) Language added in v1.8.0

func (Deptrac) Language() string

func (Deptrac) Tool added in v1.8.0

func (Deptrac) Tool(root string, runner ports.Runner) string

type GoList added in v1.8.0

type GoList struct{}

GoList is the adapter for Go. It needs no extra tool: `go list` reports each package's imports, and the rules are matched against the packages' folders, the module path of go.mod removed.

func (GoList) Applies added in v1.8.0

func (GoList) Applies(root string) bool

func (GoList) Check added in v1.8.0

func (g GoList) Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)

func (GoList) ID added in v1.8.0

func (GoList) ID() string

func (GoList) Install added in v1.8.0

func (GoList) Install() string

func (GoList) Language added in v1.8.0

func (GoList) Language() string

func (GoList) Tool added in v1.8.0

func (GoList) Tool(_ string, runner ports.Runner) string

type ImportLinter added in v1.8.0

type ImportLinter struct{}

ImportLinter is the adapter for Python: https://github.com/seddonym/import-linter. It uses the project's virtual environment (.venv, venv) or a `lint-imports` on the PATH, and never installs it.

func (ImportLinter) Applies added in v1.8.0

func (ImportLinter) Applies(root string) bool

func (ImportLinter) Check added in v1.8.0

func (l ImportLinter) Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)

func (ImportLinter) ID added in v1.8.0

func (ImportLinter) ID() string

func (ImportLinter) Install added in v1.8.0

func (ImportLinter) Install() string

func (ImportLinter) Language added in v1.8.0

func (ImportLinter) Language() string

func (ImportLinter) Tool added in v1.8.0

func (ImportLinter) Tool(root string, runner ports.Runner) string

type Jdeps added in v1.8.0

type Jdeps struct{}

Jdeps is the adapter for Java and Kotlin: jdeps, which ships with the JDK. It reads compiled classes, not sources, so the project must be built first; the rules' source folders (src/main/java/com/acme/orders) are matched as packages (com.acme.orders).

func (Jdeps) Applies added in v1.8.0

func (Jdeps) Applies(root string) bool

func (Jdeps) Check added in v1.8.0

func (j Jdeps) Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)

func (Jdeps) ID added in v1.8.0

func (Jdeps) ID() string

func (Jdeps) Install added in v1.8.0

func (Jdeps) Install() string

func (Jdeps) Language added in v1.8.0

func (Jdeps) Language() string

func (Jdeps) Tool added in v1.8.0

func (Jdeps) Tool(_ string, runner ports.Runner) string

type Outcome

type Outcome struct {
	Tool      string     `json:"tool"`
	Conflicts []Conflict `json:"conflicts"`
}

Outcome is what an adapter found.

type Row

type Row struct {
	Rule     string `json:"rule"`
	Module   string `json:"module"`
	MustNot  string `json:"must_not_depend_on"`
	MayUse   string `json:"may_depend_on"`
	PackRule string `json:"pack_rule,omitempty"`
}

Row is one materialized rule: the project's real paths, as stack.md section 5 writes them.

Jump to

Keyboard shortcuts

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