conformance

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 9 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 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
	// 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.

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) Language

func (DependencyCruiser) Language() string

func (DependencyCruiser) Tool

func (DependencyCruiser) Tool(root 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