validation

package
v1.233.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package validation contains provider-neutral validation diagnostics and their common output representations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AffectedFiles

func AffectedFiles(base string) ([]string, error)

AffectedFiles returns repository-relative files changed between HEAD and its merge-base with base. When base is empty, it uses the GitHub event's base SHA (when available), then the GitHub base branch, and finally origin/HEAD.

Deleted paths are intentionally retained. Callers can use them to decide whether a dependent validator must run, while skipping files that can no longer be read.

func ApplyEditorConfigSettings

func ApplyEditorConfigSettings(cfg *ecconfig.Config, settings *schema.EditorConfig)

ApplyEditorConfigSettings applies the validate.editorconfig ignore_defaults and disable_* settings to a checker configuration. A setting only ever turns a behavior on, exactly like the standalone command when its flag is not set.

func EditorConfigFiles

func EditorConfigFiles(root string, cfg *ecconfig.Config, globExcludes []string) ([]string, error)

EditorConfigFiles returns the files EditorConfig Checker should validate under root.

Inside a Git work tree the candidates are exactly what Git reports with "ls-files --cached --others --exclude-standard", so ignored paths such as vendored components and workdirs are never checked. Outside Git the directory is walked. Candidates are then filtered by the glob patterns (validate.editorconfig.exclude), by the checker's own exclude regular expressions (honoring ignore_defaults), and by allowed content type. Both kinds of pattern match root-relative paths, so the result does not depend on the working directory.

Returned paths are root joined with the root-relative path, so a relative root yields relative paths and an absolute root yields absolute ones.

func EditorConfigSettingsFromMap

func EditorConfigSettingsFromMap(config map[string]any) (schema.EditorConfig, error)

EditorConfigSettingsFromMap decodes the validate.editorconfig section of a raw configuration document. A missing or absent section yields zero settings.

func ExcludePaths

func ExcludePaths(paths []string, patterns []string) ([]string, error)

ExcludePaths removes paths matching any repository-relative glob pattern. Patterns use forward slashes and support doublestar (for example, "tests/fixtures/**") on every platform.

func IsAtmosConfigPath

func IsAtmosConfigPath(path string) bool

IsAtmosConfigPath reports whether path is one of the project-local Atmos configuration files read by the CLI configuration loader.

func Rich

func Rich(report Report, options RichOptions) string

Rich renders a report as deterministic source excerpts. It intentionally degrades to a complete header-only finding when a source cannot be read; presentation must never hide a validation failure.

func SelectEditorConfigFiles

func SelectEditorConfigFiles(paths, selected []string) []string

SelectEditorConfigFiles keeps only the paths that are also in selected, comparing absolute cleaned paths. A nil selection keeps everything.

func SourceExcerpt

func SourceExcerpt(diagnostic *Diagnostic, root string) ([]string, int, int)

SourceExcerpt reads a diagnostic's source with one surrounding line on either side. It returns the lines, their first line number, and the last affected line. Missing sources and invalid locations return no excerpt, never a rendering error.

Types

type Diagnostic

type Diagnostic struct {
	Source   string
	RuleID   string
	Severity Severity
	Message  string
	File     string
	Line     int
	Column   int
	// EndLine and EndColumn optionally identify a multi-line finding. They are
	// primarily used by human renderers and CI annotations; zero means the
	// location ends at Line/Column.
	EndLine   int
	EndColumn int
}

Diagnostic is a source location and message emitted by a validator.

type EditorConfigDisableOverride

type EditorConfigDisableOverride struct {
	FlagName string
	Source   *bool
	Target   *bool
}

EditorConfigDisableOverride pairs a --disable-* flag name with the atmos.yaml source field and the editorconfig-checker target field it feeds.

func EditorConfigDisableOverrides

func EditorConfigDisableOverrides(settings *schema.EditorConfig, target *ecconfig.Config) []EditorConfigDisableOverride

EditorConfigDisableOverrides lists every disable_* setting of validate.editorconfig together with the editorconfig-checker field it controls.

type Report

type Report struct {
	Diagnostics         []Diagnostic
	FilesChecked        int
	Target              string
	RenderedDiagnostics string
}

Report is the complete result of one validator invocation.

func FromGCCText

func FromGCCText(source, message string) Report

FromGCCText converts the location-bearing text produced by existing stack validation into normalized diagnostics. Lines that do not carry a source location become a single file-less finding so rich output never discards useful validation context.

func (Report) HasErrors

func (r Report) HasErrors() bool

HasErrors reports whether the report contains at least one error.

func (Report) SARIF

func (r Report) SARIF() ([]byte, error)

SARIF serializes the report as an indented SARIF 2.1.0 document.

func (Report) ToAnnotations

func (r Report) ToAnnotations() []ci.Annotation

ToAnnotations maps the report to provider-neutral CI annotations.

type RichOptions

type RichOptions struct {
	Root  string
	Width int
	Color bool
}

RichOptions controls a human-oriented diagnostic rendering. Root resolves relative diagnostic paths, Width is the available terminal width (or zero for the standard fallback), and Color is normally derived from Atmos's terminal policy by callers.

func DefaultRichOptions

func DefaultRichOptions(root string) RichOptions

DefaultRichOptions obtains the standard terminal capabilities. Keeping this separate lets tests and command callers supply deterministic settings.

type Severity

type Severity string

Severity is the normalized severity of a validation finding.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityNotice  Severity = "notice"
)

Jump to

Keyboard shortcuts

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