package stylecheck
import "honnef.co/go/tools/stylecheck"
Package stylecheck contains analyzes that enforce style rules. Most of the recommendations made are universally agreed upon by the wider Go community. Some analyzes, however, implement stricter rules that not everyone will agree with. In the context of Staticcheck, these analyzes are not enabled by default.
For the most part it is recommended to follow the advice given by the analyzers that are enabled by default, but you may want to disable additional analyzes on a case by case basis.
Index ¶
- Variables
- func CheckBlankImports(pass *analysis.Pass) (interface{}, error)
- func CheckContextFirstArg(pass *analysis.Pass) (interface{}, error)
- func CheckDefaultCaseOrder(pass *analysis.Pass) (interface{}, error)
- func CheckDotImports(pass *analysis.Pass) (interface{}, error)
- func CheckDuplicatedImports(pass *analysis.Pass) (interface{}, error)
- func CheckErrorReturn(pass *analysis.Pass) (interface{}, error)
- func CheckErrorStrings(pass *analysis.Pass) (interface{}, error)
- func CheckErrorVarNames(pass *analysis.Pass) (interface{}, error)
- func CheckExportedFunctionDocs(pass *analysis.Pass) (interface{}, error)
- func CheckExportedTypeDocs(pass *analysis.Pass) (interface{}, error)
- func CheckExportedVarDocs(pass *analysis.Pass) (interface{}, error)
- func CheckHTTPStatusCodes(pass *analysis.Pass) (interface{}, error)
- func CheckIncDec(pass *analysis.Pass) (interface{}, error)
- func CheckInvisibleCharacters(pass *analysis.Pass) (interface{}, error)
- func CheckNames(pass *analysis.Pass) (interface{}, error)
- func CheckPackageComment(pass *analysis.Pass) (interface{}, error)
- func CheckReceiverNames(pass *analysis.Pass) (interface{}, error)
- func CheckReceiverNamesIdentical(pass *analysis.Pass) (interface{}, error)
- func CheckTimeNames(pass *analysis.Pass) (interface{}, error)
- func CheckUnexportedReturn(pass *analysis.Pass) (interface{}, error)
- func CheckYodaConditions(pass *analysis.Pass) (interface{}, error)
Variables ¶
var Analyzers = lint.InitializeAnalyzers(Docs, map[string]*analysis.Analyzer{ "ST1000": { Run: CheckPackageComment, }, "ST1001": { Run: CheckDotImports, Requires: []*analysis.Analyzer{generated.Analyzer, config.Analyzer}, }, "ST1003": { Run: CheckNames, Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer, config.Analyzer}, }, "ST1005": { Run: CheckErrorStrings, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "ST1006": { Run: CheckReceiverNames, Requires: []*analysis.Analyzer{buildir.Analyzer, generated.Analyzer}, }, "ST1008": { Run: CheckErrorReturn, Requires: []*analysis.Analyzer{buildir.Analyzer}, }, "ST1011": { Run: CheckTimeNames, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "ST1012": { Run: CheckErrorVarNames, }, "ST1013": { Run: CheckHTTPStatusCodes, Requires: []*analysis.Analyzer{generated.Analyzer, tokenfile.Analyzer, config.Analyzer, inspect.Analyzer}, }, "ST1015": { Run: CheckDefaultCaseOrder, Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer, tokenfile.Analyzer}, }, "ST1016": { Run: CheckReceiverNamesIdentical, Requires: []*analysis.Analyzer{buildir.Analyzer, generated.Analyzer}, }, "ST1017": { Run: CheckYodaConditions, Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer, tokenfile.Analyzer}, }, "ST1018": { Run: CheckInvisibleCharacters, Requires: []*analysis.Analyzer{inspect.Analyzer}, }, "ST1019": { Run: CheckDuplicatedImports, Requires: []*analysis.Analyzer{generated.Analyzer}, }, "ST1020": { Run: CheckExportedFunctionDocs, Requires: []*analysis.Analyzer{generated.Analyzer, inspect.Analyzer}, }, "ST1021": { Run: CheckExportedTypeDocs, Requires: []*analysis.Analyzer{generated.Analyzer, inspect.Analyzer}, }, "ST1022": { Run: CheckExportedVarDocs, Requires: []*analysis.Analyzer{generated.Analyzer, inspect.Analyzer}, }, "ST1023": sharedcheck.RedundantTypeInDeclarationChecker("should", false), })
var Docs = lint.Markdownify(map[string]*lint.RawDocumentation{ "ST1000": { Title: `Incorrect or missing package comment`, Text: "" /* 167 byte string literal not displayed */, Since: "2019.1", NonDefault: true, MergeIf: lint.MergeIfAny, }, "ST1001": { Title: `Dot imports are discouraged`, Text: "" /* 902 byte string literal not displayed */, Since: "2019.1", Options: []string{"dot_import_whitelist"}, MergeIf: lint.MergeIfAny, }, "ST1003": { Title: `Poorly chosen identifier`, Text: "" /* 359 byte string literal not displayed */, Since: "2019.1", NonDefault: true, Options: []string{"initialisms"}, MergeIf: lint.MergeIfAny, }, "ST1005": { Title: `Incorrectly formatted error string`, Text: "" /* 497 byte string literal not displayed */, Since: "2019.1", MergeIf: lint.MergeIfAny, }, "ST1006": { Title: `Poorly chosen receiver name`, Text: "" /* 727 byte string literal not displayed */, Since: "2019.1", MergeIf: lint.MergeIfAny, }, "ST1008": { Title: `A function's error value should be its last return value`, Text: `A function's error value should be its last return value.`, Since: `2019.1`, MergeIf: lint.MergeIfAny, }, "ST1011": { Title: `Poorly chosen name for variable of type \'time.Duration\'`, Text: "" /* 304 byte string literal not displayed */, Since: `2019.1`, MergeIf: lint.MergeIfAny, }, "ST1012": { Title: `Poorly chosen name for error variable`, Text: `Error variables that are part of an API should be called \'errFoo\' or \'ErrFoo\'.`, Since: "2019.1", MergeIf: lint.MergeIfAny, }, "ST1013": { Title: `Should use constants for HTTP error codes, not magic numbers`, Text: "" /* 363 byte string literal not displayed */, Since: "2019.1", Options: []string{"http_status_code_whitelist"}, MergeIf: lint.MergeIfAny, }, "ST1015": { Title: `A switch's default case should be the first or last case`, Since: "2019.1", MergeIf: lint.MergeIfAny, }, "ST1016": { Title: `Use consistent method receiver names`, Since: "2019.1", NonDefault: true, MergeIf: lint.MergeIfAny, }, "ST1017": { Title: `Don't use Yoda conditions`, Text: "" /* 330 byte string literal not displayed */, Since: "2019.2", MergeIf: lint.MergeIfAny, }, "ST1018": { Title: `Avoid zero-width and control characters in string literals`, Since: "2019.2", MergeIf: lint.MergeIfAny, }, "ST1019": { Title: `Importing the same package multiple times`, Text: "" /* 713 byte string literal not displayed */, Since: "2020.1", MergeIf: lint.MergeIfAny, }, "ST1020": { Title: "The documentation of an exported function should start with the function's name", Text: "" /* 466 byte string literal not displayed */, Since: "2020.1", NonDefault: true, MergeIf: lint.MergeIfAny, }, "ST1021": { Title: "The documentation of an exported type should start with type's name", Text: "" /* 466 byte string literal not displayed */, Since: "2020.1", NonDefault: true, MergeIf: lint.MergeIfAny, }, "ST1022": { Title: "The documentation of an exported variable or constant should start with variable's name", Text: "" /* 466 byte string literal not displayed */, Since: "2020.1", NonDefault: true, MergeIf: lint.MergeIfAny, }, "ST1023": { Title: "Redundant type in variable declaration", Since: "2021.1", NonDefault: true, MergeIf: lint.MergeIfAll, }, })
Functions ¶
func CheckBlankImports ¶
func CheckContextFirstArg ¶
func CheckDefaultCaseOrder ¶
func CheckDotImports ¶
func CheckDuplicatedImports ¶
func CheckErrorReturn ¶
func CheckErrorStrings ¶
func CheckErrorVarNames ¶
func CheckExportedFunctionDocs ¶
func CheckExportedTypeDocs ¶
func CheckExportedVarDocs ¶
func CheckHTTPStatusCodes ¶
func CheckIncDec ¶
func CheckInvisibleCharacters ¶
func CheckNames ¶
func CheckPackageComment ¶
func CheckReceiverNames ¶
func CheckReceiverNamesIdentical ¶
func CheckTimeNames ¶
func CheckUnexportedReturn ¶
CheckUnexportedReturn checks that exported functions on exported types do not return unexported types.
func CheckYodaConditions ¶
Source Files ¶
analysis.go doc.go lint.go names.go
- Version
- v0.4.2
- Published
- Feb 16, 2023
- Platform
- windows/amd64
- Imports
- 27 packages
- Last checked
- 6 minutes ago –
Tools for package owners.