fixes

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fix

type Fix interface {
	// Name returns the unique name for the fix, this should correlate with the
	// violation title & rule name that the fix is meant to address.
	Name() string
	Fix(fc *FixCandidate, opts *RuntimeOptions) ([]FixResult, error)
}

Fix is the interface that must be implemented by all fixes.

func NewDefaultFixes

func NewDefaultFixes() []Fix

NewDefaultFixes returns a list of default fixes that are applied by the fix command. When a new fix is added, it should be added to this list.

type FixCandidate

type FixCandidate struct {
	Filename string
	Contents []byte
}

FixCandidate is the input to a Fix method and represents a file in need of fixing.

type FixResult

type FixResult struct {
	Contents []byte
}

FixResult is returned from the Fix method and contains the new contents or fix recommendations. In future this might support diff based updates, or renames.

type Fmt

type Fmt struct {
	// NameOverride allows this fix config to also be registered under another name, see note
	// in Name().
	NameOverride string
	// OPAFmtOpts are the options to pass to OPA's format.SourceWithOpts
	// function.
	OPAFmtOpts format.Opts
}

func (*Fmt) Fix

func (f *Fmt) Fix(fc *FixCandidate, _ *RuntimeOptions) ([]FixResult, error)

func (*Fmt) Name

func (f *Fmt) Name() string

type NoWhitespaceComment

type NoWhitespaceComment struct{}

func (*NoWhitespaceComment) Fix

func (*NoWhitespaceComment) Name

func (*NoWhitespaceComment) Name() string

type RuntimeOptions

type RuntimeOptions struct {
	Locations []ast.Location
}

RuntimeOptions are the options that are passed to the Fix method when the Fix is executed. Location based fixes will have the locations populated by the caller.

type UseAssignmentOperator

type UseAssignmentOperator struct{}

func (*UseAssignmentOperator) Fix

func (*UseAssignmentOperator) Name

func (*UseAssignmentOperator) Name() string

Jump to

Keyboard shortcuts

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