goanalysis

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: GPL-3.0 Imports: 41 Imported by: 0

Documentation

Overview

Package goanalysis defines the implementation of the checker commands. The same code drives the multi-analysis driver, the single-analysis driver that is conventionally provided for convenience along with each analysis package, and the test driver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdjustPos

func AdjustPos(line, nonAdjLine, adjLine int) int

AdjustPos is a hack to get the right line to display. It should not be used outside some specific cases.

func DummyRun

func DummyRun(_ *analysis.Pass) (any, error)

func EndOfLinePos

func EndOfLinePos(f *token.File, line int) token.Pos

func GetFilePositionFor

func GetFilePositionFor(fset *token.FileSet, p token.Pos) token.Position

func GetGoFilePosition

func GetGoFilePosition(pass *analysis.Pass, f *ast.File) (token.Position, bool)

Types

type Diagnostic

type Diagnostic struct {
	analysis.Diagnostic
	Analyzer *analysis.Analyzer
	Position token.Position
	Pkg      *packages.Package
	File     *token.File
}

type EncodingIssue

type EncodingIssue struct {
	FromLinter           string
	Text                 string
	Severity             string
	Pos                  token.Position
	LineRange            *result.Range
	SuggestedFixes       []analysis.SuggestedFix
	ExpectNoLint         bool
	ExpectedNoLintLinter string
}

type Fact

type Fact struct {
	Path string // non-empty only for object facts
	Fact analysis.Fact
}

type Issue

type Issue struct {
	*result.Issue
	Pass *analysis.Pass
}

func NewIssue

func NewIssue(issue *result.Issue, pass *analysis.Pass) *Issue

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

func NewLinter

func NewLinter(name, desc string, analyzers []*analysis.Analyzer, cfg map[string]map[string]any) *Linter

func NewLinterFromAnalyzer added in v2.2.0

func NewLinterFromAnalyzer(analyzer *analysis.Analyzer) *Linter

func (*Linter) Desc

func (lnt *Linter) Desc() string

func (*Linter) LoadMode

func (lnt *Linter) LoadMode() LoadMode

func (*Linter) Name

func (lnt *Linter) Name() string

func (*Linter) Run

func (lnt *Linter) Run(_ context.Context, lintCtx *linter.Context) ([]*result.Issue, error)

func (*Linter) UseOriginalPackages

func (lnt *Linter) UseOriginalPackages()

func (*Linter) WithConfig added in v2.2.0

func (lnt *Linter) WithConfig(cfg map[string]any) *Linter

func (*Linter) WithContextSetter

func (lnt *Linter) WithContextSetter(cs func(*linter.Context)) *Linter

func (*Linter) WithDesc added in v2.2.0

func (lnt *Linter) WithDesc(desc string) *Linter

func (*Linter) WithIssuesReporter

func (lnt *Linter) WithIssuesReporter(r func(*linter.Context) []*Issue) *Linter

func (*Linter) WithLoadMode

func (lnt *Linter) WithLoadMode(loadMode LoadMode) *Linter

func (*Linter) WithVersion added in v2.2.0

func (lnt *Linter) WithVersion(v int) *Linter

type LoadMode

type LoadMode int
const (
	LoadModeNone LoadMode = iota
	LoadModeSyntax
	LoadModeTypesInfo
	LoadModeWholeProgram
)

func (LoadMode) String

func (loadMode LoadMode) String() string

type MetaLinter

type MetaLinter struct {
	// contains filtered or unexported fields
}

func NewMetaLinter

func NewMetaLinter(linters []*Linter) *MetaLinter

func (MetaLinter) Desc

func (MetaLinter) Desc() string

func (MetaLinter) Name

func (MetaLinter) Name() string

func (MetaLinter) Run

func (ml MetaLinter) Run(_ context.Context, lintCtx *linter.Context) ([]*result.Issue, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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