lint

package
v0.0.0-...-ff0a6c6 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2017 License: MIT, BSD-3-Clause Imports: 17 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 IsBlank

func IsBlank(id ast.Expr) bool

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

func IsGoVersion

func IsGoVersion(version string) bool

func IsIdent

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

func IsZero

func IsZero(expr ast.Expr) bool

Types

type ByPosition

type ByPosition []Problem

func (ByPosition) Len

func (p ByPosition) Len() int

func (ByPosition) Less

func (p ByPosition) Less(i, j int) bool

func (ByPosition) Swap

func (p ByPosition) Swap(i, j int)

type Checker

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

type File

type File struct {
	Pkg      *Pkg
	File     *ast.File
	Filename string
	Fset     *token.FileSet
	Program  *loader.Program
	// contains filtered or unexported fields
}

file represents a file being linted.

func (*File) BoolConst

func (f *File) BoolConst(expr ast.Expr) bool

func (*File) EnclosingSSAFunction

func (f *File) EnclosingSSAFunction(node Positioner) *ssa.Function

func (*File) Errorf

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

func (*File) ExprToInt

func (f *File) ExprToInt(expr ast.Expr) (int64, bool)

func (*File) ExprToString

func (f *File) ExprToString(expr ast.Expr) (string, bool)

func (*File) IsBoolConst

func (f *File) IsBoolConst(expr ast.Expr) bool

func (*File) IsFunctionCallName

func (f *File) IsFunctionCallName(node ast.Node, name string) bool

func (*File) IsFunctionCallNameAny

func (f *File) IsFunctionCallNameAny(node ast.Node, names ...string) bool

func (*File) IsGenerated

func (f *File) IsGenerated() bool

func (*File) IsMain

func (f *File) IsMain() bool

func (*File) IsNil

func (f *File) IsNil(expr ast.Expr) bool

func (*File) IsTest

func (f *File) IsTest() bool

func (*File) Render

func (f *File) Render(x interface{}) string

func (*File) RenderArgs

func (f *File) RenderArgs(args []ast.Expr) string

func (*File) Source

func (f *File) Source() []byte

func (*File) Walk

func (f *File) Walk(fn func(ast.Node) bool)

type Func

type Func func(*File)

type Ignore

type Ignore struct {
	Pattern string
	Checks  []string
}

type Linter

type Linter struct {
	Checker Checker
	Ignores []Ignore
}

A Linter lints Go source code.

func (*Linter) Lint

func (l *Linter) Lint(lprog *loader.Program) map[string][]Problem

type Pkg

type Pkg struct {
	TypesPkg  *types.Package
	TypesInfo types.Info
	SSAPkg    *ssa.Package
	PkgInfo   *loader.PackageInfo
	// 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

	// If the problem has a suggested fix (the minority case),
	// ReplacementLine is a full replacement for the relevant line of the source file.
	ReplacementLine string
}

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
	Packages []*Pkg
}

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