lint

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: MIT, MIT Imports: 18 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 FilterChecks

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

Types

type Check

type Check struct {
	Fn              Func
	ID              string
	FilterGenerated bool
}

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 {
	Program *Program
	// 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

func (*Job) NodePackage

func (j *Job) NodePackage(node Positioner) *Pkg

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
	*packages.Package
	Config config.Config
}

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
	Checker  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
	InitialFunctions []*ssa.Function
	AllPackages      []*packages.Package
	AllFunctions     []*ssa.Function
	Files            []*ast.File
	GoVersion        int
	// contains filtered or unexported fields
}

func (*Program) DisplayPosition

func (prog *Program) DisplayPosition(p token.Pos) token.Position

func (*Program) File

func (prog *Program) File(node Positioner) *ast.File

func (*Program) Fset

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

func (*Program) Package

func (prog *Program) Package(path string) *packages.Package

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