analysis

package
v0.0.0-...-ad0a63f Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteKey

func DeleteKey(field *fleetpkg.Field, key string, pass *Pass) (modified bool, err error)

DeleteKey deletes the specified key from the AST associated with the given field. If pass.Fix is false, then this is a no-op.

func VisitFields

func VisitFields(fields []*fleetpkg.Field, v func(*fleetpkg.Field) error) error

VisitFields can be used to iterate over non-flat fields. Use this when you need to analyze attributes of non-leaf fields.

Types

type AST

type AST struct {
	File     *ast.File
	Modified bool // Modified tracks whether File has been modified.
}

type Analyzer

type Analyzer struct {
	Name        string
	Description string
	CanFix      bool
	Requires    []*Analyzer

	Flags flag.FlagSet

	Run func(*Pass) (interface{}, error)
}

type Diagnostic

type Diagnostic struct {
	Pos      Pos
	Category string
	Message  string
	Related  []RelatedInformation `json:"Related,omitempty"`
}

type Pass

type Pass struct {
	Analyzer *Analyzer

	Fix bool // Should the analyzer apply fixes to AST?

	// Field information.
	Fields []*fleetpkg.Field // Fields from every file.
	Flat   []*fleetpkg.Field // Flat view of all fields sorted by file and line number.

	// Map of file paths to the AST of that file. This is available when Fix is true.
	// Analyzers may add, modify, and delete map attributes, but they should not
	// add or remove entire field list entries (any operation that changes indices
	// in YAML paths would break other analyzers).
	AST map[string]*AST

	// ResultOf provides the inputs to this analysis pass, which are
	// the corresponding results of its prerequisite analyzers.
	// The map keys are the elements of Analysis.Required,
	// and the type of each corresponding value is the required
	// analysis's ResultType.
	ResultOf map[*Analyzer]interface{}

	Report func(Diagnostic)
}

type Pos

type Pos struct {
	File string
	Line int
	Col  int
}

func NewPos

func NewPos(meta fleetpkg.FileMetadata) Pos

func (Pos) MarshalJSON

func (p Pos) MarshalJSON() ([]byte, error)

func (Pos) String

func (p Pos) String() string

type Printer

type Printer func(diags []Diagnostic, w io.Writer)

type RelatedInformation

type RelatedInformation struct {
	Pos     Pos
	Message string
}

Directories

Path Synopsis
Package fieldgroup performs analysis of field groups to ensure they contain a valid 'type'.
Package fieldgroup performs analysis of field groups to ensure they contain a valid 'type'.
Package objectmapping performs analysis of fields to ensure they provide a specific mapping for all fields.
Package objectmapping performs analysis of fields to ensure they provide a specific mapping for all fields.

Jump to

Keyboard shortcuts

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