Documentation ¶
Overview ¶
Package rule implements revive's linting rules.
Index ¶
- type AddConstantRule
- type ArgumentsLimitRule
- type AtomicRule
- type BannedCharsRule
- type BareReturnRule
- type BlankImportsRule
- type BoolLiteralRule
- type CallToGCRule
- type CognitiveComplexityRule
- type CommentSpacingsRule
- type CommentsDensityRule
- type ConfusingNamingRule
- type ConfusingResultsRule
- type ConstantLogicalExprRule
- type ContextAsArgumentRule
- type ContextKeysType
- type CyclomaticRule
- type DataRaceRule
- type DeepExitRule
- type DeferRule
- type DotImportsRule
- type DuplicatedImportsRule
- type EarlyReturnRule
- type EmptyBlockRule
- type EmptyLinesRule
- type EnforceMapStyleRule
- type EnforceRepeatedArgTypeStyleRule
- type EnforceSliceStyleRule
- type ErrorNamingRule
- type ErrorReturnRule
- type ErrorStringsRule
- type ErrorfRule
- type ExportedRule
- type FileHeaderRule
- type FlagParamRule
- type FunctionLength
- type FunctionResultsLimitRule
- type GetReturnRule
- type IdenticalBranchesRule
- type IfReturnRule
- type ImportAliasNamingRule
- type ImportShadowingRule
- type ImportsBlocklistRule
- type IncrementDecrementRule
- type IndentErrorFlowRule
- type LineLengthLimitRule
- type MaxControlNestingRule
- type MaxPublicStructsRule
- type ModifiesParamRule
- type ModifiesValRecRule
- type NestedStructs
- type OptimizeOperandsOrderRule
- type PackageCommentsRule
- type RangeRule
- type RangeValAddress
- type RangeValInClosureRule
- type ReceiverNamingRule
- type RedefinesBuiltinIDRule
- type RedundantImportAlias
- type StringFormatRule
- type StringOfIntRule
- type StructTagRule
- type SuperfluousElseRule
- type TimeEqualRule
- type TimeNamingRule
- type UncheckedTypeAssertionRule
- type UnconditionalRecursionRule
- type UnexportedNamingRule
- type UnexportedReturnRule
- type UnhandledErrorRule
- type UnnecessaryStmtRule
- type UnreachableCodeRule
- type UnusedParamRule
- type UnusedReceiverRule
- type UseAnyRule
- type UselessBreak
- type VarDeclarationsRule
- type VarNamingRule
- type WaitGroupByValueRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddConstantRule ¶
AddConstantRule lints unused params in functions.
type ArgumentsLimitRule ¶
ArgumentsLimitRule lints given else constructs.
func (*ArgumentsLimitRule) Name ¶
func (*ArgumentsLimitRule) Name() string
Name returns the rule name.
type AtomicRule ¶
type AtomicRule struct{}
AtomicRule lints given else constructs.
type BannedCharsRule ¶
BannedCharsRule checks if a file contains banned characters.
type BareReturnRule ¶
type BareReturnRule struct{}
BareReturnRule lints given else constructs.
type BlankImportsRule ¶
type BlankImportsRule struct{}
BlankImportsRule lints given else constructs.
type BoolLiteralRule ¶
type BoolLiteralRule struct{}
BoolLiteralRule warns when logic expressions contains Boolean literals.
type CallToGCRule ¶
type CallToGCRule struct{}
CallToGCRule lints calls to the garbage collector.
type CognitiveComplexityRule ¶
CognitiveComplexityRule lints given else constructs.
func (*CognitiveComplexityRule) Name ¶
func (*CognitiveComplexityRule) Name() string
Name returns the rule name.
type CommentSpacingsRule ¶ added in v1.3.9
CommentSpacingsRule check the whether there is a space between the comment symbol( // ) and the start of the comment text
func (*CommentSpacingsRule) Name ¶ added in v1.3.9
func (*CommentSpacingsRule) Name() string
Name yields this rule name.
type CommentsDensityRule ¶ added in v1.3.9
CommentsDensityRule lints given else constructs.
func (*CommentsDensityRule) Name ¶ added in v1.3.9
func (*CommentsDensityRule) Name() string
Name returns the rule name.
type ConfusingNamingRule ¶
type ConfusingNamingRule struct{}
ConfusingNamingRule lints method names that differ only by capitalization
func (*ConfusingNamingRule) Name ¶
func (*ConfusingNamingRule) Name() string
Name returns the rule name.
type ConfusingResultsRule ¶
type ConfusingResultsRule struct{}
ConfusingResultsRule lints given function declarations
func (*ConfusingResultsRule) Name ¶
func (*ConfusingResultsRule) Name() string
Name returns the rule name.
type ConstantLogicalExprRule ¶
type ConstantLogicalExprRule struct{}
ConstantLogicalExprRule warns on constant logical expressions.
func (*ConstantLogicalExprRule) Name ¶
func (*ConstantLogicalExprRule) Name() string
Name returns the rule name.
type ContextAsArgumentRule ¶
ContextAsArgumentRule lints given else constructs.
func (*ContextAsArgumentRule) Name ¶
func (*ContextAsArgumentRule) Name() string
Name returns the rule name.
type ContextKeysType ¶
type ContextKeysType struct{}
ContextKeysType lints given else constructs.
type CyclomaticRule ¶
CyclomaticRule lints given else constructs.
type DataRaceRule ¶
type DataRaceRule struct{}
DataRaceRule lints assignments to value method-receivers.
type DeepExitRule ¶
type DeepExitRule struct{}
DeepExitRule lints program exit at functions other than main or init.
type DeferRule ¶
DeferRule lints unused params in functions.
type DotImportsRule ¶
DotImportsRule lints given else constructs.
type DuplicatedImportsRule ¶
type DuplicatedImportsRule struct{}
DuplicatedImportsRule lints given else constructs.
func (*DuplicatedImportsRule) Name ¶
func (*DuplicatedImportsRule) Name() string
Name returns the rule name.
type EarlyReturnRule ¶
type EarlyReturnRule struct{}
EarlyReturnRule finds opportunities to reduce nesting by inverting the condition of an "if" block.
func (*EarlyReturnRule) CheckIfElse ¶ added in v1.3.9
CheckIfElse evaluates the rule against an ifelse.Chain.
type EmptyBlockRule ¶
type EmptyBlockRule struct{}
EmptyBlockRule lints given else constructs.
type EmptyLinesRule ¶
type EmptyLinesRule struct{}
EmptyLinesRule lints empty lines in blocks.
type EnforceMapStyleRule ¶ added in v1.3.9
EnforceMapStyleRule implements a rule to enforce `make(map[type]type)` over `map[type]type{}`.
func (*EnforceMapStyleRule) Name ¶ added in v1.3.9
func (*EnforceMapStyleRule) Name() string
Name returns the rule name.
type EnforceRepeatedArgTypeStyleRule ¶ added in v1.3.9
type EnforceRepeatedArgTypeStyleRule struct { sync.Mutex // contains filtered or unexported fields }
EnforceRepeatedArgTypeStyleRule implements a rule to enforce repeated argument type style.
func (*EnforceRepeatedArgTypeStyleRule) Apply ¶ added in v1.3.9
func (r *EnforceRepeatedArgTypeStyleRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure
Apply applies the rule to a given file.
func (*EnforceRepeatedArgTypeStyleRule) Name ¶ added in v1.3.9
func (*EnforceRepeatedArgTypeStyleRule) Name() string
Name returns the name of the linter rule.
type EnforceSliceStyleRule ¶ added in v1.3.9
EnforceSliceStyleRule implements a rule to enforce `make([]type)` over `[]type{}`.
func (*EnforceSliceStyleRule) Name ¶ added in v1.3.9
func (*EnforceSliceStyleRule) Name() string
Name returns the rule name.
type ErrorNamingRule ¶
type ErrorNamingRule struct{}
ErrorNamingRule lints given else constructs.
type ErrorReturnRule ¶
type ErrorReturnRule struct{}
ErrorReturnRule lints given else constructs.
type ErrorStringsRule ¶
ErrorStringsRule lints given else constructs.
type ErrorfRule ¶
type ErrorfRule struct{}
ErrorfRule lints given else constructs.
type ExportedRule ¶
ExportedRule lints given else constructs.
type FileHeaderRule ¶
FileHeaderRule lints given else constructs.
type FlagParamRule ¶
type FlagParamRule struct{}
FlagParamRule lints given else constructs.
type FunctionLength ¶
FunctionLength lint.
type FunctionResultsLimitRule ¶
FunctionResultsLimitRule lints given else constructs.
func (*FunctionResultsLimitRule) Name ¶
func (*FunctionResultsLimitRule) Name() string
Name returns the rule name.
type GetReturnRule ¶
type GetReturnRule struct{}
GetReturnRule lints given else constructs.
type IdenticalBranchesRule ¶
type IdenticalBranchesRule struct{}
IdenticalBranchesRule warns on constant logical expressions.
func (*IdenticalBranchesRule) Name ¶
func (*IdenticalBranchesRule) Name() string
Name returns the rule name.
type IfReturnRule ¶
type IfReturnRule struct{}
IfReturnRule lints given else constructs.
type ImportAliasNamingRule ¶ added in v1.3.9
ImportAliasNamingRule lints import alias naming.
func (*ImportAliasNamingRule) Name ¶ added in v1.3.9
func (*ImportAliasNamingRule) Name() string
Name returns the rule name.
type ImportShadowingRule ¶
type ImportShadowingRule struct{}
ImportShadowingRule lints given else constructs.
func (*ImportShadowingRule) Name ¶
func (*ImportShadowingRule) Name() string
Name returns the rule name.
type ImportsBlocklistRule ¶ added in v1.3.9
ImportsBlocklistRule lints given else constructs.
func (*ImportsBlocklistRule) Name ¶ added in v1.3.9
func (*ImportsBlocklistRule) Name() string
Name returns the rule name.
type IncrementDecrementRule ¶
type IncrementDecrementRule struct{}
IncrementDecrementRule lints given else constructs.
func (*IncrementDecrementRule) Name ¶
func (*IncrementDecrementRule) Name() string
Name returns the rule name.
type IndentErrorFlowRule ¶
type IndentErrorFlowRule struct{}
IndentErrorFlowRule lints given else constructs.
func (*IndentErrorFlowRule) CheckIfElse ¶ added in v1.3.9
CheckIfElse evaluates the rule against an ifelse.Chain.
func (*IndentErrorFlowRule) Name ¶
func (*IndentErrorFlowRule) Name() string
Name returns the rule name.
type LineLengthLimitRule ¶
LineLengthLimitRule lints given else constructs.
func (*LineLengthLimitRule) Name ¶
func (*LineLengthLimitRule) Name() string
Name returns the rule name.
type MaxControlNestingRule ¶ added in v1.3.9
MaxControlNestingRule lints given else constructs.
func (*MaxControlNestingRule) Name ¶ added in v1.3.9
func (*MaxControlNestingRule) Name() string
Name returns the rule name.
type MaxPublicStructsRule ¶
MaxPublicStructsRule lints given else constructs.
func (*MaxPublicStructsRule) Name ¶
func (*MaxPublicStructsRule) Name() string
Name returns the rule name.
type ModifiesParamRule ¶
type ModifiesParamRule struct{}
ModifiesParamRule lints given else constructs.
func (*ModifiesParamRule) Name ¶
func (*ModifiesParamRule) Name() string
Name returns the rule name.
type ModifiesValRecRule ¶
type ModifiesValRecRule struct{}
ModifiesValRecRule lints assignments to value method-receivers.
func (*ModifiesValRecRule) Name ¶
func (*ModifiesValRecRule) Name() string
Name returns the rule name.
type NestedStructs ¶
type NestedStructs struct{}
NestedStructs lints nested structs.
type OptimizeOperandsOrderRule ¶
type OptimizeOperandsOrderRule struct{}
OptimizeOperandsOrderRule lints given else constructs.
func (*OptimizeOperandsOrderRule) Name ¶
func (*OptimizeOperandsOrderRule) Name() string
Name returns the rule name.
type PackageCommentsRule ¶
type PackageCommentsRule struct {
// contains filtered or unexported fields
}
PackageCommentsRule lints the package comments. It complains if there is no package comment, or if it is not of the right form. This has a notable false positive in that a package comment could rightfully appear in a different file of the same package, but that's not easy to fix since this linter is file-oriented.
func (*PackageCommentsRule) Name ¶
func (*PackageCommentsRule) Name() string
Name returns the rule name.
type RangeRule ¶
type RangeRule struct{}
RangeRule lints given else constructs.
type RangeValAddress ¶
type RangeValAddress struct{}
RangeValAddress lints
type RangeValInClosureRule ¶
type RangeValInClosureRule struct{}
RangeValInClosureRule lints given else constructs.
func (*RangeValInClosureRule) Name ¶
func (*RangeValInClosureRule) Name() string
Name returns the rule name.
type ReceiverNamingRule ¶
type ReceiverNamingRule struct{}
ReceiverNamingRule lints given else constructs.
func (*ReceiverNamingRule) Name ¶
func (*ReceiverNamingRule) Name() string
Name returns the rule name.
type RedefinesBuiltinIDRule ¶
type RedefinesBuiltinIDRule struct{}
RedefinesBuiltinIDRule warns when a builtin identifier is shadowed.
func (*RedefinesBuiltinIDRule) Name ¶
func (*RedefinesBuiltinIDRule) Name() string
Name returns the rule name.
type RedundantImportAlias ¶ added in v1.3.9
type RedundantImportAlias struct{}
RedundantImportAlias lints given else constructs.
func (*RedundantImportAlias) Name ¶ added in v1.3.9
func (*RedundantImportAlias) Name() string
Name returns the rule name.
type StringFormatRule ¶
type StringFormatRule struct{}
StringFormatRule lints strings and/or comments according to a set of regular expressions given as Arguments
func (StringFormatRule) ParseArgumentsTest ¶
func (StringFormatRule) ParseArgumentsTest(arguments lint.Arguments) *string
ParseArgumentsTest is a public wrapper around w.parseArguments used for testing. Returns the error message provided to panic, or nil if no error was encountered
type StringOfIntRule ¶
type StringOfIntRule struct{}
StringOfIntRule warns when logic expressions contains Boolean literals.
type StructTagRule ¶
StructTagRule lints struct tags.
type SuperfluousElseRule ¶
type SuperfluousElseRule struct{}
SuperfluousElseRule lints given else constructs.
func (*SuperfluousElseRule) CheckIfElse ¶ added in v1.3.9
CheckIfElse evaluates the rule against an ifelse.Chain.
func (*SuperfluousElseRule) Name ¶
func (*SuperfluousElseRule) Name() string
Name returns the rule name.
type TimeEqualRule ¶
type TimeEqualRule struct{}
TimeEqualRule shows where "==" and "!=" used for equality check time.Time
type TimeNamingRule ¶
type TimeNamingRule struct{}
TimeNamingRule lints given else constructs.
type UncheckedTypeAssertionRule ¶ added in v1.3.9
UncheckedTypeAssertionRule lints missing or ignored `ok`-value in danymic type casts.
func (*UncheckedTypeAssertionRule) Name ¶ added in v1.3.9
func (*UncheckedTypeAssertionRule) Name() string
Name returns the rule name.
type UnconditionalRecursionRule ¶
type UnconditionalRecursionRule struct{}
UnconditionalRecursionRule lints given else constructs.
func (*UnconditionalRecursionRule) Name ¶
func (*UnconditionalRecursionRule) Name() string
Name returns the rule name.
type UnexportedNamingRule ¶
type UnexportedNamingRule struct{}
UnexportedNamingRule lints wrongly named unexported symbols.
func (*UnexportedNamingRule) Name ¶
func (*UnexportedNamingRule) Name() string
Name returns the rule name.
type UnexportedReturnRule ¶
type UnexportedReturnRule struct{}
UnexportedReturnRule lints given else constructs.
func (*UnexportedReturnRule) Name ¶
func (*UnexportedReturnRule) Name() string
Name returns the rule name.
type UnhandledErrorRule ¶
UnhandledErrorRule lints given else constructs.
func (*UnhandledErrorRule) Name ¶
func (*UnhandledErrorRule) Name() string
Name returns the rule name.
type UnnecessaryStmtRule ¶
type UnnecessaryStmtRule struct{}
UnnecessaryStmtRule warns on unnecessary statements.
func (*UnnecessaryStmtRule) Name ¶
func (*UnnecessaryStmtRule) Name() string
Name returns the rule name.
type UnreachableCodeRule ¶
type UnreachableCodeRule struct{}
UnreachableCodeRule lints unreachable code.
func (*UnreachableCodeRule) Name ¶
func (*UnreachableCodeRule) Name() string
Name returns the rule name.
type UnusedParamRule ¶
UnusedParamRule lints unused params in functions.
type UnusedReceiverRule ¶
UnusedReceiverRule lints unused params in functions.
func (*UnusedReceiverRule) Name ¶
func (*UnusedReceiverRule) Name() string
Name returns the rule name.
type UseAnyRule ¶
type UseAnyRule struct{}
UseAnyRule lints given else constructs.
type UselessBreak ¶
type UselessBreak struct{}
UselessBreak lint rule.
type VarDeclarationsRule ¶
type VarDeclarationsRule struct{}
VarDeclarationsRule lints given else constructs.
func (*VarDeclarationsRule) Name ¶
func (*VarDeclarationsRule) Name() string
Name returns the rule name.
type VarNamingRule ¶
VarNamingRule lints given else constructs.
type WaitGroupByValueRule ¶
type WaitGroupByValueRule struct{}
WaitGroupByValueRule lints sync.WaitGroup passed by copy in functions.
func (*WaitGroupByValueRule) Name ¶
func (*WaitGroupByValueRule) Name() string
Name returns the rule name.
Source Files ¶
- add-constant.go
- argument-limit.go
- atomic.go
- banned-characters.go
- bare-return.go
- blank-imports.go
- bool-literal-in-expr.go
- call-to-gc.go
- cognitive-complexity.go
- comment-spacings.go
- comments-density.go
- confusing-naming.go
- confusing-results.go
- constant-logical-expr.go
- context-as-argument.go
- context-keys-type.go
- cyclomatic.go
- datarace.go
- deep-exit.go
- defer.go
- doc.go
- dot-imports.go
- duplicated-imports.go
- early-return.go
- empty-block.go
- empty-lines.go
- enforce-map-style.go
- enforce-repeated-arg-type-style.go
- enforce-slice-style.go
- error-naming.go
- error-return.go
- error-strings.go
- errorf.go
- exported.go
- file-header.go
- flag-param.go
- function-length.go
- function-result-limit.go
- get-return.go
- identical-branches.go
- if-return.go
- import-alias-naming.go
- import-shadowing.go
- imports-blocklist.go
- increment-decrement.go
- indent-error-flow.go
- line-length-limit.go
- max-control-nesting.go
- max-public-structs.go
- modifies-param.go
- modifies-value-receiver.go
- nested-structs.go
- optimize-operands-order.go
- package-comments.go
- range-val-address.go
- range-val-in-closure.go
- range.go
- receiver-naming.go
- redefines-builtin-id.go
- redundant-import-alias.go
- string-format.go
- string-of-int.go
- struct-tag.go
- superfluous-else.go
- time-equal.go
- time-naming.go
- unchecked-type-assertion.go
- unconditional-recursion.go
- unexported-naming.go
- unexported-return.go
- unhandled-error.go
- unnecessary-stmt.go
- unreachable-code.go
- unused-param.go
- unused-receiver.go
- use-any.go
- useless-break.go
- utils.go
- var-declarations.go
- var-naming.go
- waitgroup-by-value.go