lint

package
v1.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectFiles

func CollectFiles(paths []string, recursive bool) ([]string, error)

CollectFiles resolves file paths from the provided sources. If a path is a directory, it collects all YAML/YML files within it. When recursive is true, it walks subdirectories as well.

func FormatJSON

func FormatJSON(w io.Writer, output *Output) error

FormatJSON writes the linting output in JSON format to the writer.

func FormatOutput

func FormatOutput(w io.Writer, output *Output, format string) error

FormatOutput writes linting output in the specified format.

func FormatPlain

func FormatPlain(w io.Writer, output *Output) error

FormatPlain writes the linting output in plain text format to the writer.

func FormatYAML

func FormatYAML(w io.Writer, output *Output) error

FormatYAML writes the linting output in YAML format to the writer.

func ReadFromStdin

func ReadFromStdin(r io.Reader) ([]byte, error)

ReadFromStdin reads all data from a reader (intended for stdin).

Types

type Input added in v1.28.0

type Input struct {
	Name    string
	Content []byte
	// Expanded marks findings as referring to expanded content.
	Expanded bool
}

Input is in-memory content to lint, such as an expanded declarative document.

type Output

type Output struct {
	TotalCount int      `json:"total_count" yaml:"total_count"`
	FailCount  int      `json:"fail_count"  yaml:"fail_count"`
	Results    []Result `json:"results"     yaml:"results"`
}

Output contains the aggregated linting results across all files.

func Bytes

func Bytes(
	fileBytes []byte,
	ruleSet *rulesets.RuleSet,
	failSeverity string,
	onlyFailures bool,
	fileName string,
) (*Output, error)

Bytes lints raw file bytes against a pre-parsed ruleset.

func Content

func Content(
	content []byte,
	ruleSetBytes []byte,
	failSeverity string,
	onlyFailures bool,
	sourceName string,
) (*Output, error)

Content lints raw content bytes against a ruleset provided as bytes. This is useful for linting stdin or other non-file sources.

func File

func File(
	filePath string,
	ruleSetBytes []byte,
	failSeverity string,
	onlyFailures bool,
) (*Output, error)

File reads a file from disk and lints it against the provided ruleset.

func Files

func Files(
	filePaths []string,
	ruleSetBytes []byte,
	failSeverity string,
	onlyFailures bool,
) (*Output, error)

Files lints multiple files against the same ruleset, returning aggregated results.

func Inputs added in v1.28.0

func Inputs(
	inputs []Input,
	ruleSetBytes []byte,
	failSeverity string,
	onlyFailures bool,
) (*Output, error)

Inputs lints in-memory inputs against the same ruleset, returning aggregated results.

type Result

type Result struct {
	Message  string `json:"message"        yaml:"message"`
	Path     string `json:"path"           yaml:"path"`
	Severity string `json:"severity"       yaml:"severity"`
	RuleID   string `json:"rule_id"        yaml:"rule_id"`
	Line     int    `json:"line"           yaml:"line"`
	Column   int    `json:"column"         yaml:"column"`
	File     string `json:"file,omitempty" yaml:"file,omitempty"`
	// Expanded is true when Line and Column refer to the expanded document
	// (lint --expand), not to the original source file.
	Expanded bool `json:"expanded,omitempty" yaml:"expanded,omitempty"`
}

Result represents a single linting violation found in a file.

type Severity

type Severity int

Severity represents the severity level of a linting violation.

const (
	// SeverityHint is the lowest severity level.
	SeverityHint Severity = iota
	// SeverityInfo represents informational violations.
	SeverityInfo
	// SeverityWarn represents warning violations.
	SeverityWarn
	// SeverityError represents error violations (highest severity).
	SeverityError
)

func ParseSeverity

func ParseSeverity(s string) Severity

ParseSeverity converts a severity string to its Severity enum value. Returns SeverityWarn for unrecognized or empty strings, which is a conservative middle-ground: results without a severity are treated as warnings rather than being silently ignored or incorrectly elevated.

func (Severity) String

func (s Severity) String() string

String returns the string representation of a Severity level.

Jump to

Keyboard shortcuts

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