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 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) Language() string
- func (DependencyCruiser) Tool(root string, runner ports.Runner) string
- 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 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
// 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.
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) Language ¶
func (DependencyCruiser) Language() string
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.