linter

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Overview

Package linter provides the shared lint pipeline used by both the CLI and the LSP server.

The pipeline: config discovery → parse → semantic model → rule execution → violation collection. Callers use LintFile to run the pipeline and then apply their own processor chain (via CLIProcessors or LSPProcessors) to filter and transform the results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CLIProcessors

func CLIProcessors() (*processor.Chain, *processor.InlineDirectiveFilter)

CLIProcessors returns the standard CLI processor chain and the inline directive filter (the caller needs it for processor.InlineDirectiveFilter.AdditionalViolations).

func EnabledRuleCodes

func EnabledRuleCodes(cfg *config.Config) []string

EnabledRuleCodes returns the set of rule codes that are active for the given config. Includes registered rules, BuildKit captured rules, and semantic construction rules.

func LSPProcessors

func LSPProcessors() *processor.Chain

LSPProcessors returns the LSP processor chain. The LSP chain omits path normalization, path exclusion, and snippet attachment since those are CLI-specific concerns.

Types

type Channel

type Channel interface {
	Log(level Level, msg string)
	Progress(title string, pct int) // -1 = indeterminate
	Warn(msg string)
}

Channel receives diagnostic output from the lint/fix pipeline. Implementations map to environment-specific UX (LSP notifications, CLI stderr, etc.).

type Input

type Input struct {
	// FilePath is used for config discovery and violation locations.
	FilePath string

	// Content is the file content to lint. If nil, LintFile reads from FilePath.
	Content []byte

	// Config is the resolved configuration. If nil, LintFile loads from FilePath.
	Config *config.Config

	// BuildContext provides context-aware checks (e.g. .dockerignore).
	// If nil, context-aware checks are skipped.
	BuildContext rules.BuildContext

	// Channel receives progress and diagnostic output. Nil means silent.
	Channel Channel
}

Input configures a single invocation of LintFile.

type Level

type Level int

Level is a log level for the Channel interface.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
)

type Result

type Result struct {
	// Violations are raw violations before processor filtering.
	Violations []rules.Violation

	// AsyncPlan contains planned async check requests from AsyncRule implementations.
	// The caller is responsible for executing these (if slow checks are enabled).
	AsyncPlan []async.CheckRequest

	// ParseResult is the parsed Dockerfile (AST, stages, source, BuildKit warnings).
	ParseResult *dockerfile.ParseResult

	// Config is the resolved config (loaded or passed in via Input).
	Config *config.Config
}

Result contains the output of LintFile.

func LintFile

func LintFile(input Input) (*Result, error)

LintFile runs the full lint pipeline for one file. It returns raw violations before processor filtering.

Jump to

Keyboard shortcuts

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