Documentation
¶
Index ¶
- func NewAnalyzer(config *Configuration) *analysis.Analyzer
- type CheckSet
- type CheckType
- type Configuration
- type Cursor
- func (c *Cursor) Len() int
- func (c *Cursor) Next() bool
- func (c *Cursor) NextNode() ast.Node
- func (c *Cursor) Nth(n int) ast.Stmt
- func (c *Cursor) Previous() bool
- func (c *Cursor) PreviousNode() ast.Node
- func (c *Cursor) Save() func()
- func (c *Cursor) SetChecker(ct CheckType)
- func (c *Cursor) Stmt() ast.Stmt
- type WSL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAnalyzer ¶
func NewAnalyzer(config *Configuration) *analysis.Analyzer
Types ¶
type CheckSet ¶
type CheckSet map[CheckType]struct{}
CheckSet is a set of checks to run.
func DefaultChecks ¶
func DefaultChecks() CheckSet
func NewCheckSet ¶
type CheckType ¶
type CheckType int
CheckType is a type that represents a checker to run.
const ( CheckInvalid CheckType = iota CheckAssign CheckBranch CheckDecl CheckDefer CheckExpr CheckFor CheckGo CheckIf CheckIncDec CheckLabel CheckRange CheckReturn CheckSelect CheckSend CheckSwitch CheckTypeSwitch // CheckAfterBlock ensures there's a newline after each block. CheckAfterBlock // CheckAppend only allows assignments of `append` to be cuddled with other // assignments if it's a variable used in the append statement, e.g. // // a := 1 // x = append(x, a) // . CheckAppend // CheckAssignExclusive only allows assignments of either new variables or // re-assignment of existing ones, e.g. // // a := 1 // b := 2 // // a = 1 // b = 2 // . CheckAssignExclusive // CheckAssignExpr will check so assignments are not cuddled with expression // nodes, e.g. // // t1.Fn1() // // x := t1.Fn2() // t1.Fn3() // . CheckAssignExpr // CheckErr force error checking to follow immediately after an error // variable is assigned, e.g. // // _, err := someFn() // if err != nil { // panic(err) // } // . CheckErr CheckLeadingWhitespace CheckTrailingWhitespace //nolint:godoclint // No need to document // CheckTypes only used for reporting. CheckCaseTrailingNewline )
Each checker is represented by a CheckType that is used to enable or disable the check. A check can either be of a specific built-in keyword or custom checks.
func CheckFromString ¶
type Configuration ¶
type Configuration struct {
IncludeGenerated bool
AllowFirstInBlock bool
AllowWholeBlock bool
BranchMaxLines int
CaseMaxLines int
Checks CheckSet
}
func NewConfig ¶
func NewConfig() *Configuration
func NewWithChecks ¶
func NewWithChecks( defaultChecks string, enable []string, disable []string, ) (*Configuration, error)
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor holds a list of statements and a pointer to where in the list we are. Each block gets a new cursor and can be used to check previous or coming statements.
func (*Cursor) PreviousNode ¶
func (*Cursor) SetChecker ¶
Click to show internal directories.
Click to hide internal directories.