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 ¶
- func Config(root string, rows []Row) map[string]any
- func DeptracConfig(root string, rows []Row, paths []string) (cfg string, forbidden map[string]string, layers map[string]string)
- func Expand(root, glob string, suffixes ...string) []string
- func LinterConfig(root string, rows []Row) (cfg string, src bool, contracts int)
- func Paths(cell string) []string
- func Pattern(glob string, capture bool) string
- func Roots(rows []Row) []string
- func Sibling(glob string) string
- func Supported() []string
- type Adapter
- type Conflict
- type DependencyCruiser
- func (DependencyCruiser) Applies(root string) bool
- func (d DependencyCruiser) Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)
- func (DependencyCruiser) ID() string
- func (DependencyCruiser) Install() string
- func (DependencyCruiser) Language() string
- func (DependencyCruiser) Tool(root string, runner ports.Runner) string
- type Deptrac
- func (Deptrac) Applies(root string) bool
- func (d Deptrac) Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)
- func (Deptrac) ID() string
- func (Deptrac) Install() string
- func (Deptrac) Language() string
- func (Deptrac) Tool(root string, runner ports.Runner) string
- type GoList
- type ImportLinter
- func (ImportLinter) Applies(root string) bool
- func (l ImportLinter) Check(ctx context.Context, root, tool string, rows []Row, runner ports.Runner) (Outcome, error)
- func (ImportLinter) ID() string
- func (ImportLinter) Install() string
- func (ImportLinter) Language() string
- func (ImportLinter) Tool(root string, runner ports.Runner) string
- type Jdeps
- type Outcome
- type Row
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Config ¶
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
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
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 ¶
Paths splits a cell into path globs: comma separated, annotations such as "(another slice)" dropped, "-" and empty entries skipped.
func Pattern ¶
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".
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.
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) ID ¶
func (DependencyCruiser) ID() string
func (DependencyCruiser) Install ¶ added in v1.8.0
func (DependencyCruiser) Install() string
func (DependencyCruiser) Language ¶
func (DependencyCruiser) Language() 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.
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.
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) 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
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).
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.