fix

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: 0BSD Imports: 17 Imported by: 0

Documentation

Overview

Package fix coordinates selected lint fixes over one immutable source file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applied

type Applied struct {
	RuleID  string
	FixName string
	Range   source.Range
}

Applied records one complete named fix included in the result.

type ImportAction

type ImportAction string

ImportAction identifies one coordinator-owned import operation.

const (
	ImportAdd    ImportAction = "add"
	ImportRemove ImportAction = "remove"
)

type ImportChange

type ImportChange struct {
	Action ImportAction
	Path   string
	Name   string
}

ImportChange records one deterministic import operation required by fixes.

type Options

type Options struct {
	AllowSuggestion bool
	AllowUnsafe     bool
	Format          glippyformat.Options
	Validate        func(*source.File) error
}

Options controls explicit non-default safety classes and formatter policy.

type Rejection

type Rejection struct {
	RuleID  string
	FixName string
	Range   source.Range
	Reason  RejectionReason
	Message string
}

Rejection records one complete named fix left unapplied.

type RejectionReason

type RejectionReason string

RejectionReason is one stable reason a selected fix was not applied.

const (
	RejectionMissingFix    RejectionReason = "missing-fix"
	RejectionStaleSource   RejectionReason = "stale-source"
	RejectionSuggestion    RejectionReason = "suggestion-not-selected"
	RejectionUnsafe        RejectionReason = "unsafe"
	RejectionInvalidSafety RejectionReason = "invalid-safety"
	RejectionInvalidRange  RejectionReason = "invalid-range"
	RejectionInvalidText   RejectionReason = "invalid-text"
	RejectionConflict      RejectionReason = "conflict"
	RejectionValidation    RejectionReason = "validation"
)

type Result

type Result struct {
	Bytes         []byte
	Applied       []Applied
	Rejected      []Rejection
	ImportChanges []ImportChange
}

Result is one validated, formatter-normalized in-memory transaction.

func Coordinate

func Coordinate(file *source.File, selections []Selection, options Options) (Result, error)

Coordinate validates, coordinates, applies, reparses, and formats selected fixes.

type Selection

type Selection struct {
	Diagnostic rules.Diagnostic
	FixName    string
}

Selection chooses one named fix from one source-versioned diagnostic.

func Select

func Select(diagnostics []rules.Diagnostic, options SelectionOptions) ([]Selection, error)

Select chooses the only authorized named fix offered by each diagnostic.

func SelectSafe

func SelectSafe(diagnostics []rules.Diagnostic) ([]Selection, error)

SelectSafe chooses the only safe named fix offered by each diagnostic.

type SelectionOptions

type SelectionOptions struct {
	AllowSafe       bool
	AllowSuggestion bool
	AllowUnsafe     bool
}

SelectionOptions identifies the independently authorized fix classes.

type Transaction

type Transaction struct {
	Result Result
	Status WriteStatus
}

Transaction binds an in-memory coordination result to its disk outcome.

func CoordinateAndReplace

func CoordinateAndReplace(
	snapshot *filesystem.Snapshot,
	selections []Selection,
	options Options,
) (Transaction, error)

CoordinateAndReplace coordinates fixes and atomically replaces one snapshot.

type WriteStatus

type WriteStatus string

WriteStatus distinguishes coordinated bytes from confirmed disk state.

const (
	WriteNotPerformed      WriteStatus = "not-performed"
	WriteCompleted         WriteStatus = "completed"
	WritePossiblyCompleted WriteStatus = "possibly-completed"
)

Jump to

Keyboard shortcuts

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