toolshonnef.co/go/tools/stylecheck Index | Files

package stylecheck

import "honnef.co/go/tools/stylecheck"

Index

Variables

var Analyzers = lint.InitializeAnalyzers(Docs, map[string]*analysis.Analyzer{
	"ST1000": {
		Run: CheckPackageComment,
	},
	"ST1001": {
		Run:      CheckDotImports,
		Requires: []*analysis.Analyzer{facts.Generated, config.Analyzer},
	},
	"ST1003": {
		Run:      CheckNames,
		Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated, config.Analyzer},
	},
	"ST1005": {
		Run:      CheckErrorStrings,
		Requires: []*analysis.Analyzer{buildir.Analyzer},
	},
	"ST1006": {
		Run:      CheckReceiverNames,
		Requires: []*analysis.Analyzer{buildir.Analyzer, facts.Generated},
	},
	"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{facts.Generated, facts.TokenFile, config.Analyzer, inspect.Analyzer},
	},
	"ST1015": {
		Run:      CheckDefaultCaseOrder,
		Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated, facts.TokenFile},
	},
	"ST1016": {
		Run:      CheckReceiverNamesIdentical,
		Requires: []*analysis.Analyzer{buildir.Analyzer, facts.Generated},
	},
	"ST1017": {
		Run:      CheckYodaConditions,
		Requires: []*analysis.Analyzer{inspect.Analyzer, facts.Generated, facts.TokenFile},
	},
	"ST1018": {
		Run:      CheckInvisibleCharacters,
		Requires: []*analysis.Analyzer{inspect.Analyzer},
	},
	"ST1019": {
		Run:      CheckDuplicatedImports,
		Requires: []*analysis.Analyzer{facts.Generated},
	},
	"ST1020": {
		Run:      CheckExportedFunctionDocs,
		Requires: []*analysis.Analyzer{facts.Generated, inspect.Analyzer},
	},
	"ST1021": {
		Run:      CheckExportedTypeDocs,
		Requires: []*analysis.Analyzer{facts.Generated, inspect.Analyzer},
	},
	"ST1022": {
		Run:      CheckExportedVarDocs,
		Requires: []*analysis.Analyzer{facts.Generated, inspect.Analyzer},
	},
	"ST1023": sharedcheck.RedundantTypeInDeclarationChecker("should", false),
})
var Docs = lint.Markdownify(map[string]*lint.Documentation{
	"ST1000": {
		Title: `Incorrect or missing package comment`,
		Text:  "" /* 167 byte string literal not displayed */,

		Since:      "2019.1",
		NonDefault: true,
	},

	"ST1001": {
		Title: `Dot imports are discouraged`,
		Text:  "" /* 880 byte string literal not displayed */,

		Since:   "2019.1",
		Options: []string{"dot_import_whitelist"},
	},

	"ST1003": {
		Title: `Poorly chosen identifier`,
		Text:  "" /* 359 byte string literal not displayed */,

		Since:      "2019.1",
		NonDefault: true,
		Options:    []string{"initialisms"},
	},

	"ST1005": {
		Title: `Incorrectly formatted error string`,
		Text:  "" /* 485 byte string literal not displayed */,

		Since: "2019.1",
	},

	"ST1006": {
		Title: `Poorly chosen receiver name`,
		Text:  "" /* 727 byte string literal not displayed */,

		Since: "2019.1",
	},

	"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`,
	},

	"ST1011": {
		Title: "Poorly chosen name for variable of type `time.Duration`",
		Text:  "" /* 300 byte string literal not displayed */,

		Since: `2019.1`,
	},

	"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",
	},

	"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"},
	},

	"ST1015": {
		Title: `A switch's default case should be the first or last case`,
		Since: "2019.1",
	},

	"ST1016": {
		Title:      `Use consistent method receiver names`,
		Since:      "2019.1",
		NonDefault: true,
	},

	"ST1017": {
		Title: `Don't use Yoda conditions`,
		Text:  "" /* 330 byte string literal not displayed */,

		Since: "2019.2",
	},

	"ST1018": {
		Title: `Avoid zero-width and control characters in string literals`,
		Since: "2019.2",
	},

	"ST1019": {
		Title: `Importing the same package multiple times`,
		Text:  "" /* 695 byte string literal not displayed */,

		Since: "2020.1",
	},

	"ST1020": {
		Title: "The documentation of an exported function should start with the function's name",
		Text:  "" /* 458 byte string literal not displayed */,

		Since:      "2020.1",
		NonDefault: true,
	},

	"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,
	},

	"ST1022": {
		Title: "The documentation of an exported variable or constant should start with variable's name",
		Text:  "" /* 458 byte string literal not displayed */,

		Since:      "2020.1",
		NonDefault: true,
	},

	"ST1023": {
		Title:      "Redundant type in variable declaration",
		Since:      "2021.1",
		NonDefault: true,
	},
})

Functions

func CheckBlankImports

func CheckBlankImports(pass *analysis.Pass) (interface{}, error)

func CheckContextFirstArg

func CheckContextFirstArg(pass *analysis.Pass) (interface{}, error)

func CheckDefaultCaseOrder

func CheckDefaultCaseOrder(pass *analysis.Pass) (interface{}, error)

func CheckDotImports

func CheckDotImports(pass *analysis.Pass) (interface{}, error)

func CheckDuplicatedImports

func CheckDuplicatedImports(pass *analysis.Pass) (interface{}, error)

func CheckErrorReturn

func CheckErrorReturn(pass *analysis.Pass) (interface{}, error)

func CheckErrorStrings

func CheckErrorStrings(pass *analysis.Pass) (interface{}, error)

func CheckErrorVarNames

func CheckErrorVarNames(pass *analysis.Pass) (interface{}, error)

func CheckExportedFunctionDocs

func CheckExportedFunctionDocs(pass *analysis.Pass) (interface{}, error)

func CheckExportedTypeDocs

func CheckExportedTypeDocs(pass *analysis.Pass) (interface{}, error)

func CheckExportedVarDocs

func CheckExportedVarDocs(pass *analysis.Pass) (interface{}, error)

func CheckHTTPStatusCodes

func CheckHTTPStatusCodes(pass *analysis.Pass) (interface{}, error)

func CheckIncDec

func CheckIncDec(pass *analysis.Pass) (interface{}, error)

func CheckInvisibleCharacters

func CheckInvisibleCharacters(pass *analysis.Pass) (interface{}, error)

func CheckNames

func CheckNames(pass *analysis.Pass) (interface{}, error)

func CheckPackageComment

func CheckPackageComment(pass *analysis.Pass) (interface{}, error)

func CheckReceiverNames

func CheckReceiverNames(pass *analysis.Pass) (interface{}, error)

func CheckReceiverNamesIdentical

func CheckReceiverNamesIdentical(pass *analysis.Pass) (interface{}, error)

func CheckTimeNames

func CheckTimeNames(pass *analysis.Pass) (interface{}, error)

func CheckUnexportedReturn

func CheckUnexportedReturn(pass *analysis.Pass) (interface{}, error)

CheckUnexportedReturn checks that exported functions on exported types do not return unexported types.

func CheckYodaConditions

func CheckYodaConditions(pass *analysis.Pass) (interface{}, error)

Source Files

analysis.go doc.go lint.go names.go

Version
v0.2.0
Published
May 25, 2021
Platform
windows/amd64
Imports
26 packages
Last checked
6 minutes ago

Tools for package owners.