package simple
import "honnef.co/go/tools/simple"
Package simple contains a linter for Go source code.
Index ¶
- Variables
- func LintAssertNotNil(pass *analysis.Pass) (interface{}, error)
- func LintBytesBufferConversions(pass *analysis.Pass) (interface{}, error)
- func LintBytesCompare(pass *analysis.Pass) (interface{}, error)
- func LintDeclareAssign(pass *analysis.Pass) (interface{}, error)
- func LintErrorsNewSprintf(pass *analysis.Pass) (interface{}, error)
- func LintForTrue(pass *analysis.Pass) (interface{}, error)
- func LintGuardedDelete(pass *analysis.Pass) (interface{}, error)
- func LintIfBoolCmp(pass *analysis.Pass) (interface{}, error)
- func LintIfReturn(pass *analysis.Pass) (interface{}, error)
- func LintLoopAppend(pass *analysis.Pass) (interface{}, error)
- func LintLoopCopy(pass *analysis.Pass) (interface{}, error)
- func LintLoopSlide(pass *analysis.Pass) (interface{}, error)
- func LintMakeLenCap(pass *analysis.Pass) (interface{}, error)
- func LintNilCheckAroundRange(pass *analysis.Pass) (interface{}, error)
- func LintRangeStringRunes(pass *analysis.Pass) (interface{}, error)
- func LintRedundantBreak(pass *analysis.Pass) (interface{}, error)
- func LintRedundantNilCheckWithLen(pass *analysis.Pass) (interface{}, error)
- func LintRedundantSprintf(pass *analysis.Pass) (interface{}, error)
- func LintRegexpRaw(pass *analysis.Pass) (interface{}, error)
- func LintSimplerStructConversion(pass *analysis.Pass) (interface{}, error)
- func LintSimplifyTypeSwitch(pass *analysis.Pass) (interface{}, error)
- func LintSingleCaseSelect(pass *analysis.Pass) (interface{}, error)
- func LintSlicing(pass *analysis.Pass) (interface{}, error)
- func LintSortHelpers(pass *analysis.Pass) (interface{}, error)
- func LintStringsContains(pass *analysis.Pass) (interface{}, error)
- func LintTimeSince(pass *analysis.Pass) (interface{}, error)
- func LintTimeUntil(pass *analysis.Pass) (interface{}, error)
- func LintTrim(pass *analysis.Pass) (interface{}, error)
- func LintUnnecessaryBlank(pass *analysis.Pass) (interface{}, error)
Variables ¶
var Analyzers = map[string]*analysis.Analyzer{ "S1000": { Name: "S1000", Run: LintSingleCaseSelect, Doc: Docs["S1000"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1001": { Name: "S1001", Run: LintLoopCopy, Doc: Docs["S1001"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1002": { Name: "S1002", Run: LintIfBoolCmp, Doc: Docs["S1002"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1003": { Name: "S1003", Run: LintStringsContains, Doc: Docs["S1003"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1004": { Name: "S1004", Run: LintBytesCompare, Doc: Docs["S1004"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1005": { Name: "S1005", Run: LintUnnecessaryBlank, Doc: Docs["S1005"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1006": { Name: "S1006", Run: LintForTrue, Doc: Docs["S1006"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1007": { Name: "S1007", Run: LintRegexpRaw, Doc: Docs["S1007"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1008": { Name: "S1008", Run: LintIfReturn, Doc: Docs["S1008"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1009": { Name: "S1009", Run: LintRedundantNilCheckWithLen, Doc: Docs["S1009"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1010": { Name: "S1010", Run: LintSlicing, Doc: Docs["S1010"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1011": { Name: "S1011", Run: LintLoopAppend, Doc: Docs["S1011"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1012": { Name: "S1012", Run: LintTimeSince, Doc: Docs["S1012"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1016": { Name: "S1016", Run: LintSimplerStructConversion, Doc: Docs["S1016"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1017": { Name: "S1017", Run: LintTrim, Doc: Docs["S1017"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1018": { Name: "S1018", Run: LintLoopSlide, Doc: Docs["S1018"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1019": { Name: "S1019", Run: LintMakeLenCap, Doc: Docs["S1019"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1020": { Name: "S1020", Run: LintAssertNotNil, Doc: Docs["S1020"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1021": { Name: "S1021", Run: LintDeclareAssign, Doc: Docs["S1021"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1023": { Name: "S1023", Run: LintRedundantBreak, Doc: Docs["S1023"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1024": { Name: "S1024", Run: LintTimeUntil, Doc: Docs["S1024"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1025": { Name: "S1025", Run: LintRedundantSprintf, Doc: Docs["S1025"].String(), Requires: []*analysis.Analyzer{buildssa.Analyzer, inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1028": { Name: "S1028", Run: LintErrorsNewSprintf, Doc: Docs["S1028"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1029": { Name: "S1029", Run: LintRangeStringRunes, Doc: Docs["S1029"].String(), Requires: []*analysis.Analyzer{buildssa.Analyzer}, Flags: newFlagSet(), }, "S1030": { Name: "S1030", Run: LintBytesBufferConversions, Doc: Docs["S1030"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1031": { Name: "S1031", Run: LintNilCheckAroundRange, Doc: Docs["S1031"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1032": { Name: "S1032", Run: LintSortHelpers, Doc: Docs["S1032"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1033": { Name: "S1033", Run: LintGuardedDelete, Doc: Docs["S1033"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, "S1034": { Name: "S1034", Run: LintSimplifyTypeSwitch, Doc: Docs["S1034"].String(), Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated}, Flags: newFlagSet(), }, }
var Docs = map[string]*lint.Documentation{ "S1000": &lint.Documentation{ Title: `Use plain channel send or receive instead of single-case select`, Text: "" /* 199 byte string literal not displayed */, Since: "2017.1", }, "S1001": &lint.Documentation{ Title: `Replace for loop with call to copy`, Text: "" /* 151 byte string literal not displayed */, Since: "2017.1", }, "S1002": &lint.Documentation{ Title: `Omit comparison with boolean constant`, Text: `Before: if x == true {} After: if x {}`, Since: "2017.1", }, "S1003": &lint.Documentation{ Title: `Replace call to strings.Index with strings.Contains`, Text: `Before: if strings.Index(x, y) != -1 {} After: if strings.Contains(x, y) {}`, Since: "2017.1", }, "S1004": &lint.Documentation{ Title: `Replace call to bytes.Compare with bytes.Equal`, Text: `Before: if bytes.Compare(x, y) == 0 {} After: if bytes.Equal(x, y) {}`, Since: "2017.1", }, "S1005": &lint.Documentation{ Title: `Drop unnecessary use of the blank identifier`, Text: "" /* 193 byte string literal not displayed */, Since: "2017.1", }, "S1006": &lint.Documentation{ Title: `Use for { ... } for infinite loops`, Text: `For infinite loops, using for { ... } is the most idiomatic choice.`, Since: "2017.1", }, "S1007": &lint.Documentation{ Title: `Simplify regular expression by using raw string literal`, Text: `Raw string literals use ` + "`" + "" /* 340 byte string literal not displayed */+ "`" + `\A(\w+) profile: total \d+\n\z` + "`" + `)`, Since: "2017.1", }, "S1008": &lint.Documentation{ Title: `Simplify returning boolean expression`, Text: `Before: if <expr> { return true } return false After: return <expr>`, Since: "2017.1", }, "S1009": &lint.Documentation{ Title: `Omit redundant nil check on slices`, Text: "" /* 260 byte string literal not displayed */, Since: "2017.1", }, "S1010": &lint.Documentation{ Title: `Omit default slice index`, Text: `When slicing, the second index defaults to the length of the value, making s[n:len(s)] and s[n:] equivalent.`, Since: "2017.1", }, "S1011": &lint.Documentation{ Title: `Use a single append to concatenate two slices`, Text: `Before: for _, e := range y { x = append(x, e) } After: x = append(x, y...)`, Since: "2017.1", }, "S1012": &lint.Documentation{ Title: `Replace time.Now().Sub(x) with time.Since(x)`, Text: "" /* 152 byte string literal not displayed */, Since: "2017.1", }, "S1016": &lint.Documentation{ Title: `Use a type conversion instead of manually copying struct fields`, Text: "" /* 414 byte string literal not displayed */, Since: "2017.1", }, "S1017": &lint.Documentation{ Title: `Replace manual trimming with strings.TrimPrefix`, Text: "" /* 413 byte string literal not displayed */, Since: "2017.1", }, "S1018": &lint.Documentation{ Title: `Use copy for sliding elements`, Text: "" /* 257 byte string literal not displayed */, Since: "2017.1", }, "S1019": &lint.Documentation{ Title: `Simplify make call by omitting redundant arguments`, Text: "" /* 191 byte string literal not displayed */, Since: "2017.1", }, "S1020": &lint.Documentation{ Title: `Omit redundant nil check in type assertion`, Text: `Before: if _, ok := i.(T); ok && i != nil {} After: if _, ok := i.(T); ok {}`, Since: "2017.1", }, "S1021": &lint.Documentation{ Title: `Merge variable declaration and assignment`, Text: `Before: var x uint x = 1 After: var x uint = 1`, Since: "2017.1", }, "S1023": &lint.Documentation{ Title: `Omit redundant control flow`, Text: "" /* 270 byte string literal not displayed */, Since: "2017.1", }, "S1024": &lint.Documentation{ Title: `Replace x.Sub(time.Now()) with time.Until(x)`, Text: "" /* 152 byte string literal not displayed */, Since: "2017.1", }, "S1025": &lint.Documentation{ Title: `Don't use fmt.Sprintf("%s", x) unnecessarily`, Text: "" /* 548 byte string literal not displayed */, Since: "2017.1", }, "S1028": &lint.Documentation{ Title: `Simplify error construction with fmt.Errorf`, Text: `Before: errors.New(fmt.Sprintf(...)) After: fmt.Errorf(...)`, Since: "2017.1", }, "S1029": &lint.Documentation{ Title: `Range over the string directly`, Text: "" /* 424 byte string literal not displayed */, Since: "2017.1", }, "S1030": &lint.Documentation{ Title: `Use bytes.Buffer.String or bytes.Buffer.Bytes`, Text: "" /* 158 byte string literal not displayed */, Since: "2017.1", }, "S1031": &lint.Documentation{ Title: `Omit redundant nil check around loop`, Text: "" /* 286 byte string literal not displayed */, Since: "2017.1", }, "S1032": &lint.Documentation{ Title: `Use sort.Ints(x), sort.Float64s(x), and sort.Strings(x)`, Text: "" /* 252 byte string literal not displayed */, Since: "2019.1", }, "S1033": &lint.Documentation{ Title: `Unnecessary guard around call to delete`, Text: `Calling delete on a nil map is a no-op.`, Since: "2019.2", }, "S1034": &lint.Documentation{ Title: `Use result of type assertion to simplify cases`, Since: "2019.2", }, }
Functions ¶
func LintAssertNotNil ¶
func LintBytesBufferConversions ¶
func LintBytesCompare ¶
func LintDeclareAssign ¶
func LintErrorsNewSprintf ¶
func LintForTrue ¶
func LintGuardedDelete ¶
func LintIfBoolCmp ¶
func LintIfReturn ¶
func LintLoopAppend ¶
func LintLoopCopy ¶
func LintLoopSlide ¶
func LintMakeLenCap ¶
func LintNilCheckAroundRange ¶
func LintRangeStringRunes ¶
func LintRedundantBreak ¶
func LintRedundantNilCheckWithLen ¶
LintRedundantNilCheckWithLen checks for the following reduntant nil-checks:
if x == nil || len(x) == 0 {} if x != nil && len(x) != 0 {} if x != nil && len(x) == N {} (where N != 0) if x != nil && len(x) > N {} if x != nil && len(x) >= N {} (where N != 0)
func LintRedundantSprintf ¶
func LintRegexpRaw ¶
func LintSimplerStructConversion ¶
func LintSimplifyTypeSwitch ¶
func LintSingleCaseSelect ¶
func LintSlicing ¶
func LintSortHelpers ¶
func LintStringsContains ¶
func LintTimeSince ¶
func LintTimeUntil ¶
func LintTrim ¶
func LintUnnecessaryBlank ¶
Source Files ¶
analysis.go doc.go lint.go
- Version
- v0.0.1-2019.2.3
- Published
- Sep 4, 2019
- Platform
- windows/amd64
- Imports
- 20 packages
- Last checked
- 7 minutes ago –
Tools for package owners.