lint

package
v2.0.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2018 License: MIT, MIT Imports: 18 Imported by: 0

Documentation

Overview

Package lint provides the foundation for tools like gosimple.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallName

func CallName(call *ssa.CallCommon) string

func FilterDebug

func FilterDebug(instr []ssa.Instruction) []ssa.Instruction

func IsBlank

func IsBlank(id ast.Expr) bool

isBlank returns whether id is the blank identifier "_". If id == nil, the answer is false.

func IsCallTo

func IsCallTo(call *ssa.CallCommon, name string) bool

func IsExample

func IsExample(fn *ssa.Function) bool

func IsGenerated

func IsGenerated(f *ast.File) bool

func IsIdent

func IsIdent(expr ast.Expr, ident string) bool

func IsPointerLike

func IsPointerLike(T types.Type) bool

func IsZero

func IsZero(expr ast.Expr) bool

func NodeFns

func NodeFns(pkgs []*Pkg) map[ast.Node]*ssa.Function

func Preamble

func Preamble(f *ast.File) string

Types

type Checker

type Checker interface {
	Name() string
	Prefix() string
	Init(*Program)
	Funcs() map[string]Func
}

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) BoolConst

func (j *Job) BoolConst(expr ast.Expr) bool

func (*Job) Errorf

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

func (*Job) ExprToInt

func (j *Job) ExprToInt(expr ast.Expr) (int64, bool)

func (*Job) ExprToString

func (j *Job) ExprToString(expr ast.Expr) (string, bool)

func (*Job) File

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

func (*Job) IsBoolConst

func (j *Job) IsBoolConst(expr ast.Expr) bool

func (*Job) IsCallToAST

func (j *Job) IsCallToAST(node ast.Node, name string) bool

func (*Job) IsCallToAnyAST

func (j *Job) IsCallToAnyAST(node ast.Node, names ...string) bool

func (*Job) IsGoVersion

func (j *Job) IsGoVersion(minor int) bool

func (*Job) IsInMain

func (j *Job) IsInMain(node Positioner) bool

func (*Job) IsInTest

func (j *Job) IsInTest(node Positioner) bool

func (*Job) IsNil

func (j *Job) IsNil(expr ast.Expr) bool

func (*Job) NodePackage

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

func (*Job) Render

func (j *Job) Render(x interface{}) string

func (*Job) RenderArgs

func (j *Job) RenderArgs(args []ast.Expr) string

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 {
	Checker       Checker
	Ignores       []Ignore
	GoVersion     int
	ReturnIgnored bool
	// contains filtered or unexported fields
}

A Linter lints Go source code.

func (*Linter) Lint

func (l *Linter) Lint(lprog *loader.Program, conf *loader.Config) []Problem

type Pkg

type Pkg struct {
	*ssa.Package
	Info     *loader.PackageInfo
	BuildPkg *build.Package
}

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  *types.Package
	Ignored  bool
	// contains filtered or unexported fields
}

Problem represents a problem in some source code.

func (*Problem) String

func (p *Problem) String() string

type Program

type Program struct {
	SSA  *ssa.Program
	Prog *loader.Program
	// TODO(dh): Rename to InitialPackages?
	Packages         []*Pkg
	InitialFunctions []*ssa.Function
	AllFunctions     []*ssa.Function
	Files            []*ast.File
	Info             *types.Info
	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

Directories

Path Synopsis
Package lintutil provides helpers for writing linter command lines.
Package lintutil provides helpers for writing linter command lines.

Jump to

Keyboard shortcuts

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