lint

package
v0.0.0-...-6b646bb Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2019 License: MIT, BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package lint provides the foundation for tools like staticcheck

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayPosition

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

func FilterChecks

func FilterChecks(allChecks []string, checks []string) map[string]bool

func FuncName

func FuncName(f *types.Func) string

Types

type Check

type Check struct {
	Fn              Func
	ID              string
	FilterGenerated bool
	Doc             string
}

type Checker

type Checker interface {
	Name() string
	Prefix() string
	Init(*Program)
	Checks() []Check
}

type FileIgnore

type FileIgnore struct {
	File   string
	Checks []string
}

func (*FileIgnore) Match

func (fi *FileIgnore) Match(p Problem) bool

type Func

type Func func(*Job)

type GlobIgnore

type GlobIgnore struct {
	Pattern string
	Checks  []string
}

func (*GlobIgnore) Match

func (gi *GlobIgnore) Match(p Problem) bool

type Ignore

type Ignore interface {
	Match(p Problem) bool
}

type Job

type Job struct {
	Pkg       *Pkg
	GoVersion int
	// contains filtered or unexported fields
}

func (*Job) Errorf

func (j *Job) Errorf(n Positioner, format string, args ...interface{}) *Problem

func (*Job) File

func (j *Job) File(node Positioner) *ast.File

type JobStat

type JobStat struct {
	Job      string
	Duration time.Duration
}

type LineIgnore

type LineIgnore struct {
	File   string
	Line   int
	Checks []string
	// contains filtered or unexported fields
}

func (*LineIgnore) Match

func (li *LineIgnore) Match(p Problem) bool

func (*LineIgnore) String

func (li *LineIgnore) String() string

type Linter

type Linter struct {
	Checkers      []Checker
	Ignores       []Ignore
	GoVersion     int
	ReturnIgnored bool
	Config        config.Config

	MaxConcurrentJobs int
	PrintStats        bool
	// contains filtered or unexported fields
}

A Linter lints Go source code.

func (*Linter) Lint

func (l *Linter) Lint(initial []*packages.Package, stats *PerfStats) []Problem

type PerfStats

type PerfStats struct {
	PackageLoading time.Duration
	SSABuild       time.Duration
	OtherInitWork  time.Duration
	CheckerInits   map[string]time.Duration
	Jobs           []JobStat
}

func (*PerfStats) Print

func (stats *PerfStats) Print(w io.Writer)

type Pkg

type Pkg struct {
	SSA              *ssa.Package
	InitialFunctions []*ssa.Function
	*packages.Package
	Config    config.Config
	Inspector *inspector.Inspector
	// TODO(dh): this map should probably map from *ast.File, not string
	Generated map[string]bool
	// contains filtered or unexported fields
}

Pkg represents a package being linted.

type Positioner

type Positioner interface {
	Pos() token.Pos
}

type Problem

type Problem struct {
	Position token.Position // position in source file
	Text     string         // the prose that describes the problem
	Check    string
	Package  *Pkg
	Severity Severity
}

Problem represents a problem in some source code.

func (*Problem) String

func (p *Problem) String() string

type Program

type Program struct {
	SSA             *ssa.Program
	InitialPackages []*Pkg
	AllPackages     []*packages.Package
	AllFunctions    []*ssa.Function
}

func (*Program) Fset

func (prog *Program) Fset() *token.FileSet

type Severity

type Severity uint8
const (
	Error Severity = iota
	Warning
	Ignored
)

Directories

Path Synopsis
Package lintdsl provides helpers for implementing static analysis checks.
Package lintdsl provides helpers for implementing static analysis checks.
Package lintutil provides helpers for writing linter command lines.
Package lintutil provides helpers for writing linter command lines.
format
Package format provides formatters for linter problems.
Package format provides formatters for linter problems.
Package testutil provides helpers for testing staticcheck.
Package testutil provides helpers for testing staticcheck.

Jump to

Keyboard shortcuts

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