Documentation
¶
Overview ¶
Package validation contains provider-neutral validation diagnostics and their common output representations.
Index ¶
- func AffectedFiles(base string) ([]string, error)
- func ApplyEditorConfigSettings(cfg *ecconfig.Config, settings *schema.EditorConfig)
- func EditorConfigFiles(root string, cfg *ecconfig.Config, globExcludes []string) ([]string, error)
- func EditorConfigSettingsFromMap(config map[string]any) (schema.EditorConfig, error)
- func ExcludePaths(paths []string, patterns []string) ([]string, error)
- func IsAtmosConfigPath(path string) bool
- func Rich(report Report, options RichOptions) string
- func SelectEditorConfigFiles(paths, selected []string) []string
- func SourceExcerpt(diagnostic *Diagnostic, root string) ([]string, int, int)
- type Diagnostic
- type EditorConfigDisableOverride
- type Report
- type RichOptions
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AffectedFiles ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) ToAnnotations ¶
func (r Report) ToAnnotations() []ci.Annotation
ToAnnotations maps the report to provider-neutral CI annotations.
type RichOptions ¶
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.