Help us shape the future of Go! Take the 2026 Go Developer Survey

engine

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CombinedDiffStrict = "strict"
	CombinedDiffWarn   = "warn"
	CombinedDiffIgnore = "ignore"
	CombinedDiffParent = "parent"
)

Variables

View Source
var ErrStatUnsupported = errors.New("file provider stat unsupported")

Functions

func LabelRanges

func LabelRanges(path string) (map[string]core.LineRange, error)

LabelRanges returns the label line ranges for the given file by parsing directives.

func ParseChangedLines

func ParseChangedLines(diffText string) (map[string]*core.FileChanges, error)

Build changes map from a unified diff string using diff.Parser.

func ParseChangedLinesReader

func ParseChangedLinesReader(r io.Reader) (map[string]*core.FileChanges, error)

func ResolveTarget

func ResolveTarget(src, raw string) core.TargetRef

ResolveTarget resolves a selector using the configured directive grammar. Local target paths use forward slashes on every host. Workspace-root targets remain relative so callers can apply their own root.

func ValidateFixPath

func ValidateFixPath(root, target string) error

ValidateFixPath rejects directive-driven writes outside root or through symlinks.

Types

type FileProvider

type FileProvider interface {
	ReadFile(path string) ([]byte, error)
	Stat(path string) (FileStat, error)
}

FileProvider abstracts file access so alternative backends (e.g., remote blobs) can supply source/target contents without touching the local filesystem.

type FileProviderFactory

type FileProviderFactory interface {
	Match(target string) bool
	Provider(target string) (FileProvider, string, error)
}

type FileStat

type FileStat struct {
	Path    string
	Size    int64
	ModTime time.Time
}

FileStat provides minimal metadata about a file used for caching.

type GitHubFactory

type GitHubFactory struct {
	// contains filtered or unexported fields
}

GitHubFactory registers GitHub providers for multiple repositories.

func NewGitHubFactory

func NewGitHubFactory(remotes []GitHubRemote) (*GitHubFactory, error)

NewGitHubFactory constructs a provider factory for the supplied remotes.

func (*GitHubFactory) Match

func (f *GitHubFactory) Match(target string) bool

func (*GitHubFactory) Provider

func (f *GitHubFactory) Provider(target string) (FileProvider, string, error)

type GitHubRemote

type GitHubRemote struct {
	Repo       string
	DefaultRef string
	Token      string
	BaseURL    string
}

GitHubRemote describes configuration for a GitHub repository integration.

type Options

type Options struct {
	Syntax *core.DirectiveSyntax
	// ConfigOverrides records explicit CLI policies for snapshot configuration.
	ConfigOverrides map[string]bool
	// RevisionChanges and ReverseCandidates describe an immutable source snapshot.
	// RevisionChanges keys and FileChanges paths use repository forward slashes.
	RevisionChanges   map[string]*core.FileChanges
	ReverseCandidates []string
	MatchCandidates   []string
	// DependencyChanges supplies foreign changed-line evidence without adding sources.
	DependencyChanges func(string) (*core.FileChanges, error)
	// DependencyConfigChanged requests structural revalidation, not co-change evidence.
	DependencyConfigChanged func(string) bool
	Repository              *vcs.Backend
	StrictPaths             bool
	Parallelism             int
	Verbose                 bool
	Ignores                 []string // file or file#label
	IgnoreBaseDir           string   // optional configuration coordinate root
	CodeOnly                bool
	UnknownPolicy           string // error|warn|ignore
	SkipDirs                []string
	Fix                     bool
	Files                   FileProvider
	Factories               []FileProviderFactory
	CombinedDiffPolicy      string
	SuppressCoChanges       bool
	SourceFiles             []string
	StructuralFiles         []string
}

type Result

type Result struct {
	Findings   []core.Finding
	Suppressed []core.Finding
	Stats      map[string]any
}

func Lint

func Lint(diffText string, opts Options) (Result, int)

Lint evaluates the diff against directives in files.

func LintReader

func LintReader(r io.Reader, opts Options) (Result, int)

func ValidateFiles

func ValidateFiles(paths []string, opts Options) (Result, int)

ValidateFiles checks every supplied file's directive structure and targets without requiring a diff or treating existing bodies as changed.

Jump to

Keyboard shortcuts

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