lint

package
v0.0.0-2019.2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: MIT, BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Overview

Package lint provides the foundation for tools like staticcheck

Index

Constants

View Source
const (
	StateInitializing = 0
	StateGraph        = 1
	StateProcessing   = 2
	StateCumulative   = 3
)

Variables

This section is empty.

Functions

func DisplayPosition

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

func FilterChecks

func FilterChecks(allChecks []*analysis.Analyzer, checks []string) map[string]bool

func FuncName

func FuncName(f *types.Func) string

Types

type CumulativeChecker

type CumulativeChecker interface {
	Analyzer() *analysis.Analyzer
	Result() []types.Object
	ProblemObject(*token.FileSet, types.Object) Problem
}

type Documentation

type Documentation struct {
	Title      string
	Text       string
	Since      string
	NonDefault bool
	Options    []string
}

func (*Documentation) String

func (doc *Documentation) String() string

type Fact

type Fact struct {
	Path string
	Fact analysis.Fact
}

type FileIgnore

type FileIgnore struct {
	File   string
	Checks []string
}

func (*FileIgnore) Match

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

type Ignore

type Ignore interface {
	Match(p Problem) bool
}

type LineIgnore

type LineIgnore struct {
	File    string
	Line    int
	Checks  []string
	Matched bool
	Pos     token.Pos
}

func (*LineIgnore) Match

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

func (*LineIgnore) String

func (li *LineIgnore) String() string

type Linter

type Linter struct {
	Checkers           []*analysis.Analyzer
	CumulativeCheckers []CumulativeChecker
	GoVersion          int
	Config             config.Config
	Stats              Stats
}

A Linter lints Go source code.

func (*Linter) Lint

func (l *Linter) Lint(cfg *packages.Config, patterns []string) ([]Problem, error)

type Package

type Package struct {
	*packages.Package
	Imports []*Package
	// contains filtered or unexported fields
}

type Positioner

type Positioner interface {
	Pos() token.Pos
}

type Problem

type Problem struct {
	Pos      token.Position
	End      token.Position
	Message  string
	Check    string
	Severity Severity
}

Problem represents a problem in some source code.

func (*Problem) String

func (p *Problem) String() string

type Runner

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

func NewRunner

func NewRunner(stats *Stats) (*Runner, error)

func (*Runner) Run

func (r *Runner) Run(cfg *packages.Config, patterns []string, analyzers []*analysis.Analyzer, hasCumulative bool) ([]*Package, error)

Run loads packages corresponding to patterns and analyses them with analyzers. It returns the loaded packages, which contain reported diagnostics as well as extracted ignore directives.

Note that diagnostics have not been filtered at this point yet, to accomodate cumulative analyzes that require additional steps to produce diagnostics.

type Severity

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

type Stats

type Stats struct {
	State uint64

	InitialPackages          uint64
	TotalPackages            uint64
	ProcessedPackages        uint64
	ProcessedInitialPackages uint64
	Problems                 uint64
	ActiveWorkers            uint64
	TotalWorkers             uint64
}

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.

Jump to

Keyboard shortcuts

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