mirror of
https://github.com/mgechev/revive.git
synced 2025-07-05 00:28:53 +02:00
docs: fix rule descriptions (#1147)
This commit is contained in:
@ -31,7 +31,7 @@ func (wl allowList) add(kind, list string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddConstantRule lints unused params in functions.
|
// AddConstantRule suggests using constants instead of magic numbers and string literals.
|
||||||
type AddConstantRule struct {
|
type AddConstantRule struct {
|
||||||
allowList allowList
|
allowList allowList
|
||||||
ignoreFunctions []*regexp.Regexp
|
ignoreFunctions []*regexp.Regexp
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ArgumentsLimitRule lints given else constructs.
|
// ArgumentsLimitRule lints the number of arguments a function can receive.
|
||||||
type ArgumentsLimitRule struct {
|
type ArgumentsLimitRule struct {
|
||||||
max int
|
max int
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AtomicRule lints given else constructs.
|
// AtomicRule lints usages of the `sync/atomic` package.
|
||||||
type AtomicRule struct{}
|
type AtomicRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BareReturnRule lints given else constructs.
|
// BareReturnRule lints bare returns.
|
||||||
type BareReturnRule struct{}
|
type BareReturnRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BlankImportsRule lints given else constructs.
|
// BlankImportsRule lints blank imports.
|
||||||
type BlankImportsRule struct{}
|
type BlankImportsRule struct{}
|
||||||
|
|
||||||
// Name returns the rule name.
|
// Name returns the rule name.
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"golang.org/x/tools/go/ast/astutil"
|
"golang.org/x/tools/go/ast/astutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CognitiveComplexityRule lints given else constructs.
|
// CognitiveComplexityRule sets restriction for maximum cognitive complexity.
|
||||||
type CognitiveComplexityRule struct {
|
type CognitiveComplexityRule struct {
|
||||||
maxComplexity int
|
maxComplexity int
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CommentsDensityRule lints given else constructs.
|
// CommentsDensityRule enforces a minimum comment / code relation.
|
||||||
type CommentsDensityRule struct {
|
type CommentsDensityRule struct {
|
||||||
minimumCommentsDensity int64
|
minimumCommentsDensity int64
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContextAsArgumentRule lints given else constructs.
|
// ContextAsArgumentRule suggests that `context.Context` should be the first argument of a function.
|
||||||
type ContextAsArgumentRule struct {
|
type ContextAsArgumentRule struct {
|
||||||
allowTypesLUT map[string]struct{}
|
allowTypesLUT map[string]struct{}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContextKeysType lints given else constructs.
|
// ContextKeysType disallows the usage of basic types in `context.WithValue`.
|
||||||
type ContextKeysType struct{}
|
type ContextKeysType struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// Based on https://github.com/fzipp/gocyclo
|
// Based on https://github.com/fzipp/gocyclo
|
||||||
|
|
||||||
// CyclomaticRule lints given else constructs.
|
// CyclomaticRule sets restriction for maximum cyclomatic complexity.
|
||||||
type CyclomaticRule struct {
|
type CyclomaticRule struct {
|
||||||
maxComplexity int
|
maxComplexity int
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DeferRule lints unused params in functions.
|
// DeferRule lints gotchas in defer statements.
|
||||||
type DeferRule struct {
|
type DeferRule struct {
|
||||||
allow map[string]bool
|
allow map[string]bool
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DotImportsRule lints given else constructs.
|
// DotImportsRule forbids . imports.
|
||||||
type DotImportsRule struct {
|
type DotImportsRule struct {
|
||||||
allowedPackages allowPackages
|
allowedPackages allowPackages
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DuplicatedImportsRule lints given else constructs.
|
// DuplicatedImportsRule looks for packages that are imported two or more times.
|
||||||
type DuplicatedImportsRule struct{}
|
type DuplicatedImportsRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EmptyBlockRule lints given else constructs.
|
// EmptyBlockRule warns on empty code blocks.
|
||||||
type EmptyBlockRule struct{}
|
type EmptyBlockRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorNamingRule lints given else constructs.
|
// ErrorNamingRule lints naming of error variables.
|
||||||
type ErrorNamingRule struct{}
|
type ErrorNamingRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorReturnRule lints given else constructs.
|
// ErrorReturnRule ensures that the error return parameter is the last parameter.
|
||||||
type ErrorReturnRule struct{}
|
type ErrorReturnRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorStringsRule lints given else constructs.
|
// ErrorStringsRule lints error strings.
|
||||||
type ErrorStringsRule struct {
|
type ErrorStringsRule struct {
|
||||||
errorFunctions map[string]map[string]struct{}
|
errorFunctions map[string]map[string]struct{}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrorfRule lints given else constructs.
|
// ErrorfRule suggests using `fmt.Errorf` instead of `errors.New(fmt.Sprintf())`.
|
||||||
type ErrorfRule struct{}
|
type ErrorfRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -62,7 +62,7 @@ var commonMethods = map[string]bool{
|
|||||||
"Unwrap": true,
|
"Unwrap": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportedRule lints given else constructs.
|
// ExportedRule lints naming and commenting conventions on exported symbols.
|
||||||
type ExportedRule struct {
|
type ExportedRule struct {
|
||||||
stuttersMsg string
|
stuttersMsg string
|
||||||
disabledChecks disabledChecks
|
disabledChecks disabledChecks
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FileHeaderRule lints given else constructs.
|
// FileHeaderRule lints the header that each file should have.
|
||||||
type FileHeaderRule struct {
|
type FileHeaderRule struct {
|
||||||
header string
|
header string
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FlagParamRule lints given else constructs.
|
// FlagParamRule warns on boolean parameters that create a control coupling.
|
||||||
type FlagParamRule struct{}
|
type FlagParamRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FunctionResultsLimitRule lints given else constructs.
|
// FunctionResultsLimitRule limits the maximum number of results a function can return.
|
||||||
type FunctionResultsLimitRule struct {
|
type FunctionResultsLimitRule struct {
|
||||||
max int
|
max int
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetReturnRule lints given else constructs.
|
// GetReturnRule warns on getters that do not yield any result.
|
||||||
type GetReturnRule struct{}
|
type GetReturnRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IfReturnRule lints given else constructs.
|
// IfReturnRule searches for redundant `if` when returning an error.
|
||||||
type IfReturnRule struct{}
|
type IfReturnRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImportShadowingRule lints given else constructs.
|
// ImportShadowingRule spots identifiers that shadow an import.
|
||||||
type ImportShadowingRule struct{}
|
type ImportShadowingRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImportsBlocklistRule lints given else constructs.
|
// ImportsBlocklistRule disallows importing the specified packages.
|
||||||
type ImportsBlocklistRule struct {
|
type ImportsBlocklistRule struct {
|
||||||
blocklist []*regexp.Regexp
|
blocklist []*regexp.Regexp
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IncrementDecrementRule lints given else constructs.
|
// IncrementDecrementRule lints `i += 1` and `i -= 1` constructs.
|
||||||
type IncrementDecrementRule struct{}
|
type IncrementDecrementRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IndentErrorFlowRule lints given else constructs.
|
// IndentErrorFlowRule prevents redundant else statements.
|
||||||
type IndentErrorFlowRule struct{}
|
type IndentErrorFlowRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LineLengthLimitRule lints given else constructs.
|
// LineLengthLimitRule lints number of characters in a line.
|
||||||
type LineLengthLimitRule struct {
|
type LineLengthLimitRule struct {
|
||||||
max int
|
max int
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MaxControlNestingRule lints given else constructs.
|
// MaxControlNestingRule sets restriction for maximum nesting of control structures.
|
||||||
type MaxControlNestingRule struct {
|
type MaxControlNestingRule struct {
|
||||||
max int64
|
max int64
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MaxPublicStructsRule lints given else constructs.
|
// MaxPublicStructsRule lints the number of public structs in a file.
|
||||||
type MaxPublicStructsRule struct {
|
type MaxPublicStructsRule struct {
|
||||||
max int64
|
max int64
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ModifiesParamRule lints given else constructs.
|
// ModifiesParamRule warns on assignments to function parameters.
|
||||||
type ModifiesParamRule struct{}
|
type ModifiesParamRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OptimizeOperandsOrderRule lints given else constructs.
|
// OptimizeOperandsOrderRule checks inefficient conditional expressions.
|
||||||
type OptimizeOperandsOrderRule struct{}
|
type OptimizeOperandsOrderRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RangeRule lints given else constructs.
|
// RangeRule prevents redundant variables when iterating over a collection.
|
||||||
type RangeRule struct{}
|
type RangeRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RangeValInClosureRule lints given else constructs.
|
// RangeValInClosureRule warns if range value is used in a closure dispatched as goroutine.
|
||||||
type RangeValInClosureRule struct{}
|
type RangeValInClosureRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ReceiverNamingRule lints given else constructs.
|
// ReceiverNamingRule lints a receiver name.
|
||||||
type ReceiverNamingRule struct {
|
type ReceiverNamingRule struct {
|
||||||
receiverNameMaxLength int
|
receiverNameMaxLength int
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RedundantImportAlias lints given else constructs.
|
// RedundantImportAlias warns on import aliases matching the imported package name.
|
||||||
type RedundantImportAlias struct{}
|
type RedundantImportAlias struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TimeNamingRule lints given else constructs.
|
// TimeNamingRule lints the name of a time variable.
|
||||||
type TimeNamingRule struct{}
|
type TimeNamingRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UnconditionalRecursionRule lints given else constructs.
|
// UnconditionalRecursionRule warns on function calls that will lead to infinite recursion.
|
||||||
type UnconditionalRecursionRule struct{}
|
type UnconditionalRecursionRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UnexportedReturnRule lints given else constructs.
|
// UnexportedReturnRule warns when a public return is from unexported type.
|
||||||
type UnexportedReturnRule struct{}
|
type UnexportedReturnRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UnhandledErrorRule lints given else constructs.
|
// UnhandledErrorRule warns on unhandled errors returned by function calls.
|
||||||
type UnhandledErrorRule struct {
|
type UnhandledErrorRule struct {
|
||||||
ignoreList []*regexp.Regexp
|
ignoreList []*regexp.Regexp
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UnusedReceiverRule lints unused params in functions.
|
// UnusedReceiverRule lints unused receivers in functions.
|
||||||
type UnusedReceiverRule struct {
|
type UnusedReceiverRule struct {
|
||||||
// regex to check if some name is valid for unused parameter, "^_$" by default
|
// regex to check if some name is valid for unused parameter, "^_$" by default
|
||||||
allowRegex *regexp.Regexp
|
allowRegex *regexp.Regexp
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/mgechev/revive/lint"
|
"github.com/mgechev/revive/lint"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UseAnyRule lints given else constructs.
|
// UseAnyRule proposes to replace `interface{}` with its alias `any`.
|
||||||
type UseAnyRule struct{}
|
type UseAnyRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -25,7 +25,7 @@ var zeroLiteral = map[string]bool{
|
|||||||
"0i": true,
|
"0i": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// VarDeclarationsRule lints given else constructs.
|
// VarDeclarationsRule reduces redundancies around variable declaration.
|
||||||
type VarDeclarationsRule struct{}
|
type VarDeclarationsRule struct{}
|
||||||
|
|
||||||
// Apply applies the rule to given file.
|
// Apply applies the rule to given file.
|
||||||
|
@ -23,7 +23,7 @@ var knownNameExceptions = map[string]bool{
|
|||||||
"kWh": true,
|
"kWh": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// VarNamingRule lints given else constructs.
|
// VarNamingRule lints the name of a variable.
|
||||||
type VarNamingRule struct {
|
type VarNamingRule struct {
|
||||||
allowList []string
|
allowList []string
|
||||||
blockList []string
|
blockList []string
|
||||||
|
Reference in New Issue
Block a user