tools: Index | Files | Directories

package lint

import ""

Package lint provides the foundation for tools like staticcheck


Package Files

lint.go runner.go stats.go


const (
    StateInitializing = 0
    StateGraph        = 1
    StateProcessing   = 2
    StateCumulative   = 3

func DisplayPosition Uses

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

func FilterChecks Uses

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

func FuncName Uses

func FuncName(f *types.Func) string

type AnalysisMeasurementKey Uses

type AnalysisMeasurementKey struct {
    Analysis string
    Pkg      string

type CumulativeChecker Uses

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

type Documentation Uses

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

func (*Documentation) String Uses

func (doc *Documentation) String() string

type Fact Uses

type Fact struct {
    Path string
    Fact analysis.Fact

type FileIgnore Uses

type FileIgnore struct {
    File   string
    Checks []string

func (*FileIgnore) Match Uses

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

type Ignore Uses

type Ignore interface {
    Match(p Problem) bool

type LineIgnore Uses

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

func (*LineIgnore) Match Uses

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

func (*LineIgnore) String Uses

func (li *LineIgnore) String() string

type Linter Uses

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

A Linter lints Go source code.

func (*Linter) Lint Uses

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

type Package Uses

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

type Positioner Uses

type Positioner interface {
    Pos() token.Pos

type Problem Uses

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 Uses

func (p *Problem) String() string

type Runner Uses

type Runner struct {
    // contains filtered or unexported fields

func NewRunner Uses

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

func (*Runner) Run Uses

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 accommodate cumulative analyzes that require additional steps to produce diagnostics.

type Severity Uses

type Severity uint8
const (
    Error Severity = iota

type Stats Uses

type Stats struct {
    State uint32

    InitialPackages          uint32
    TotalPackages            uint32
    ProcessedPackages        uint32
    ProcessedInitialPackages uint32
    Problems                 uint32
    ActiveWorkers            uint32
    TotalWorkers             uint32
    PrintAnalyzerMeasurement func(*analysis.Analyzer, *Package, time.Duration)

func (*Stats) MeasureAnalyzer Uses

func (s *Stats) MeasureAnalyzer(analysis *analysis.Analyzer, pkg *Package, d time.Duration)


lintdslPackage lintdsl provides helpers for implementing static analysis checks.
lintutilPackage lintutil provides helpers for writing linter command lines.
lintutil/formatPackage format provides formatters for linter problems.

Package lint imports 26 packages (graph) and is imported by 16 packages. Updated 2019-10-22. Refresh now. Tools for package owners.