Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectoryPackageMismatch ¶ added in v0.26.0
type DirectoryPackageMismatch struct{}
func (*DirectoryPackageMismatch) Fix ¶ added in v0.26.0
func (d *DirectoryPackageMismatch) Fix(fc *FixCandidate, opts *RuntimeOptions) ([]FixResult, error)
Fix moves a file to the correct directory based on the package name, and relative to the base directory provided in opts. If the file is already in the correct directory, no action is taken.
func (*DirectoryPackageMismatch) Name ¶ added in v0.26.0
func (*DirectoryPackageMismatch) Name() string
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.
func NewDefaultFormatterFixes ¶ added in v0.26.0
func NewDefaultFormatterFixes() []Fix
NewDefaultFormatterFixes returns a list of default fixes that are applied by the formatter. Notably, this does not include fixers that move files around.
type FixCandidate ¶
FixCandidate is the input to a Fix method and represents a file in need of fixing.
type FixResult ¶
type FixResult struct { // Rename is used to indicate that a rename operation should be performed by the **caller**. // An example of this would be the DirectoryPackageMismatch fix, which in the context of // `regal fix` renames files as part of the fix, while when invoked as a LSP Code Action will // defer the actual rename back to the client. Rename *Rename // Title is the name of the fix applied. Title string // Root is the project root of the file fixed. This is persisted for presentation purposes, // as it makes it easier to understand the context of the fix. Root string // Contents is the new contents of the file. May be nil or identical to the original contents, // as not all fixes involve content changes. It is the responsibility of the caller to handle // this. 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.
type Fmt ¶
type Fmt struct { // OPAFmtOpts are the options to pass to OPA's format.SourceWithOpts // function. OPAFmtOpts format.Opts // NameOverride allows this fix config to also be registered under another name, see note // in Name(). NameOverride string }
func (*Fmt) Fix ¶
func (f *Fmt) Fix(fc *FixCandidate, opts *RuntimeOptions) ([]FixResult, error)
type NoWhitespaceComment ¶
type NoWhitespaceComment struct{}
func (*NoWhitespaceComment) Fix ¶
func (n *NoWhitespaceComment) Fix(fc *FixCandidate, opts *RuntimeOptions) ([]FixResult, error)
func (*NoWhitespaceComment) Name ¶
func (*NoWhitespaceComment) Name() string
type RuntimeOptions ¶
type RuntimeOptions struct { Config *config.Config // BaseDir is the base directory for the files being fixed. This is often the same as the // workspace root directory, but not necessarily. BaseDir string Locations []ast.Location Client clients.Identifier }
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 (u *UseAssignmentOperator) Fix(fc *FixCandidate, opts *RuntimeOptions) ([]FixResult, error)
func (*UseAssignmentOperator) Name ¶
func (*UseAssignmentOperator) Name() string