lint

package
v0.0.0-...-12e10be Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: Apache-2.0, BSD-3-Clause Imports: 16 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 IsZero

func IsZero(expr ast.Expr) bool

func NodeFns

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

Types

type Checker

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

type Func

type Func func(*Job)

type Ignore

type Ignore struct {
	Pattern string
	Checks  []string
}

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 Linter

type Linter struct {
	Checker   Checker
	Ignores   []Ignore
	GoVersion int
}

A Linter lints Go source code.

func (*Linter) Lint

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

type Pkg

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

Pkg represents a package being linted.

type Positioner

type Positioner interface {
	Pos() token.Pos
}

type Problem

type Problem struct {
	Position token.Pos // position in source file
	Text     string    // the prose that describes the problem
}

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
}

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