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 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.
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 ¶
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" )