lint

package
v0.0.0-...-c6dfda3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnknownType types.Type = types.Typ[types.Invalid]

UnknownType is a special sentinel value that is returned from the CheckerContext.TypeOf method instead of the nil type.

View Source
var UnknownVar = types.NewVar(
	token.NoPos,
	types.NewPackage("unknown", "unknown"),
	"unknown",
	UnknownType)

Functions

This section is empty.

Types

type Context

type Context struct {
	*SharedContext
	// contains filtered or unexported fields
}

func NewContext

func NewContext(tag string, minHeatLevel int) Context

func (*Context) MultiChangeSuggest

func (ctx *Context) MultiChangeSuggest(params MultiChangeSuggestParams)

func (*Context) Report

func (ctx *Context) Report(params ReportParams)

func (*Context) SuggestNode

func (ctx *Context) SuggestNode(params SuggestParams)

type MultiChangeSuggestParams

type MultiChangeSuggestParams struct {
	ReportPos     token.Pos
	ReportMessage string

	OldNodes []ast.Node
	NewNodes []NodeReplacement
	HotNodes []ast.Node

	UseFlatSamples bool
}

type NodeReplacement

type NodeReplacement struct {
	Text   []byte
	Syntax ast.Node
}

type ReportParams

type ReportParams struct {
	PosNode ast.Node

	Message string

	HotNodes []ast.Node

	UseFlatSamples bool
}

type SharedContext

type SharedContext struct {
	Target *Target

	Heatmap *heatmap.Index

	Filename string // Filename is a name of file that is being analyzed
	TypeName string // TypeName is a receiver name of the current func
	FuncName string // FuncName is a current func/method name

	// Sym is a currently analyzed function call symbol info.
	// Only relevant for funccall checkers.
	Sym resolve.CallInfo

	Warn func(Warning)
	// contains filtered or unexported fields
}

func (*SharedContext) EndPosition

func (ctx *SharedContext) EndPosition(n ast.Node) token.Position

func (*SharedContext) NodeText

func (ctx *SharedContext) NodeText(n ast.Node) []byte

func (*SharedContext) ObjectOf

func (ctx *SharedContext) ObjectOf(x *ast.Ident) types.Object

func (*SharedContext) Position

func (ctx *SharedContext) Position(n ast.Node) token.Position

func (*SharedContext) Reset

func (ctx *SharedContext) Reset(target *Target)

func (*SharedContext) Sprintf

func (ctx *SharedContext) Sprintf(format string, args ...interface{}) string

func (*SharedContext) TypeOf

func (ctx *SharedContext) TypeOf(x ast.Expr) types.Type

TypeOf returns the type of expression x.

Unlike TypesInfo.TypeOf, it never returns nil. Instead, it returns the Invalid type as a sentinel UnknownType value.

func (*SharedContext) VarOf

func (ctx *SharedContext) VarOf(x *ast.Ident) *types.Var

type SourceFile

type SourceFile struct {
	Syntax *ast.File
}

type SuggestParams

type SuggestParams struct {
	OldNode ast.Node
	NewNode ast.Node

	Message string

	HotNodes []ast.Node

	UseFlatSamples bool
}

type Target

type Target struct {
	Pkg   *types.Package
	Fset  *token.FileSet
	Types *types.Info
	Sizes types.Sizes
	Files []SourceFile
}

type TextEdit

type TextEdit struct {
	From        token.Pos
	To          token.Pos
	Replacement []byte
	Reformat    bool
}

type Warning

type Warning struct {
	Filename string
	Line     int
	Tag      string
	Text     string

	Fixes []TextEdit

	SamplesTime time.Duration
}

Jump to

Keyboard shortcuts

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