lint

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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 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

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.

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"`
}

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