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 EnforceSwitchStyleRule
- type ErrorNamingRule
- type ErrorReturnRule
- type ErrorStringsRule
- type ErrorfRule
- type ExportedRule
- type FileHeaderRule
- type FileLengthLimitRule
- type FilenameFormatRule
- type FlagParamRule
- type ForbiddenCallInWgGoRule
- type FunctionLength
- type FunctionResultsLimitRule
- type GetReturnRule
- type IdenticalBranchesRule
- type IdenticalIfElseIfBranchesRule
- type IdenticalIfElseIfConditionsRule
- type IdenticalSwitchBranchesRule
- type IdenticalSwitchConditionsRule
- type IfReturnRule
- type ImportAliasNamingRule
- type ImportShadowingRule
- type ImportsBlocklistRule
- type IncrementDecrementRule
- type IndentErrorFlowRule
- type InefficientMapLookupRule
- type LineLengthLimitRule
- type MaxControlNestingRule
- type MaxPublicStructsRule
- type ModifiesParamRule
- type ModifiesValRecRule
- type NestedStructs
- type OptimizeOperandsOrderRule
- type PackageCommentsRule
- type PackageDirectoryMismatchRule
- type RangeRule
- type RangeValAddress
- type RangeValInClosureRule
- type ReceiverNamingRule
- type RedefinesBuiltinIDRule
- type RedundantBuildTagRule
- type RedundantImportAlias
- type RedundantTestMainExitRule
- type StringFormatRule
- type StringOfIntRule
- type StructTagRule
- type SuperfluousElseRule
- type TimeDateRule
- type TimeEqualRule
- type TimeNamingRule
- type UncheckedTypeAssertionRule
- type UnconditionalRecursionRule
- type UnexportedNamingRule
- type UnexportedReturnRule
- type UnhandledErrorRule
- type UnnecessaryFormatRule
- type UnnecessaryIfRule
- type UnnecessaryStmtRule
- type UnreachableCodeRule
- type UnsecureURLSchemeRule
- type UnusedParamRule
- type UnusedReceiverRule
- type UseAnyRule
- type UseErrorsNewRule
- type UseFmtPrintRule
- type UseWaitGroupGoRule
- type UselessBreak
- type UselessFallthroughRule
- type VarDeclarationsRule
- type VarNamingRule
- type WaitGroupByValueRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddConstantRule ¶
type AddConstantRule struct {
// contains filtered or unexported fields
}
AddConstantRule suggests using constants instead of magic numbers and string literals.
func (*AddConstantRule) Configure ¶ added in v1.6.0
func (r *AddConstantRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
type ArgumentsLimitRule ¶
type ArgumentsLimitRule struct {
// contains filtered or unexported fields
}
ArgumentsLimitRule lints the number of arguments a function can receive.
func (*ArgumentsLimitRule) Configure ¶ added in v1.6.0
func (r *ArgumentsLimitRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*ArgumentsLimitRule) Name ¶
func (*ArgumentsLimitRule) Name() string
Name returns the rule name.
type AtomicRule ¶
type AtomicRule struct{}
AtomicRule lints usages of the `sync/atomic` package.
type BannedCharsRule ¶ added in v1.1.3
type BannedCharsRule struct {
// contains filtered or unexported fields
}
BannedCharsRule checks if a file contains banned characters.
func (*BannedCharsRule) Configure ¶ added in v1.6.0
func (r *BannedCharsRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*BannedCharsRule) Name ¶ added in v1.1.3
func (*BannedCharsRule) Name() string
Name returns the rule name.
type BareReturnRule ¶
type BareReturnRule struct{}
BareReturnRule lints bare returns.
type BlankImportsRule ¶
type BlankImportsRule struct{}
BlankImportsRule lints blank imports.
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 ¶
type CognitiveComplexityRule struct {
// contains filtered or unexported fields
}
CognitiveComplexityRule sets restriction for maximum cognitive complexity.
func (*CognitiveComplexityRule) Configure ¶ added in v1.6.0
func (r *CognitiveComplexityRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*CognitiveComplexityRule) Name ¶
func (*CognitiveComplexityRule) Name() string
Name returns the rule name.
type CommentSpacingsRule ¶ added in v1.2.5
type CommentSpacingsRule struct {
// contains filtered or unexported fields
}
CommentSpacingsRule check whether there is a space between the comment symbol( // ) and the start of the comment text.
func (*CommentSpacingsRule) Configure ¶ added in v1.6.0
func (r *CommentSpacingsRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*CommentSpacingsRule) Name ¶ added in v1.2.5
func (*CommentSpacingsRule) Name() string
Name yields this rule name.
type CommentsDensityRule ¶ added in v1.3.8
type CommentsDensityRule struct {
// contains filtered or unexported fields
}
CommentsDensityRule enforces a minimum comment / code relation.
func (*CommentsDensityRule) Configure ¶ added in v1.6.0
func (r *CommentsDensityRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*CommentsDensityRule) Name ¶ added in v1.3.8
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 ¶
type ContextAsArgumentRule struct {
// contains filtered or unexported fields
}
ContextAsArgumentRule suggests that `context.Context` should be the first argument of a function.
func (*ContextAsArgumentRule) Configure ¶ added in v1.6.0
func (r *ContextAsArgumentRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*ContextAsArgumentRule) Name ¶
func (*ContextAsArgumentRule) Name() string
Name returns the rule name.
type ContextKeysType ¶
type ContextKeysType struct{}
ContextKeysType disallows the usage of basic types in `context.WithValue`.
type CyclomaticRule ¶
type CyclomaticRule struct {
// contains filtered or unexported fields
}
CyclomaticRule sets restriction for maximum cyclomatic complexity.
func (*CyclomaticRule) Configure ¶ added in v1.6.0
func (r *CyclomaticRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
type DataRaceRule ¶ added in v1.2.2
type DataRaceRule struct{}
DataRaceRule lints assignments to value method-receivers.
func (*DataRaceRule) Name ¶ added in v1.2.2
func (*DataRaceRule) Name() string
Name returns the rule name.
type DeepExitRule ¶
type DeepExitRule struct{}
DeepExitRule lints program exit at functions other than main or init.
type DeferRule ¶ added in v1.0.3
type DeferRule struct {
// contains filtered or unexported fields
}
DeferRule lints gotchas in defer statements.
func (*DeferRule) Configure ¶ added in v1.6.0
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
type DotImportsRule ¶
type DotImportsRule struct {
// contains filtered or unexported fields
}
DotImportsRule forbids . imports.
func (*DotImportsRule) Configure ¶ added in v1.6.0
func (r *DotImportsRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
type DuplicatedImportsRule ¶
type DuplicatedImportsRule struct{}
DuplicatedImportsRule looks for packages that are imported two or more times.
func (*DuplicatedImportsRule) Name ¶
func (*DuplicatedImportsRule) Name() string
Name returns the rule name.
type EarlyReturnRule ¶ added in v1.0.3
type EarlyReturnRule struct {
// contains filtered or unexported fields
}
EarlyReturnRule finds opportunities to reduce nesting by inverting the condition of an "if" block.
func (*EarlyReturnRule) Configure ¶ added in v1.8.0
func (e *EarlyReturnRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*EarlyReturnRule) Name ¶ added in v1.0.3
func (*EarlyReturnRule) Name() string
Name returns the rule name.
type EmptyBlockRule ¶
type EmptyBlockRule struct{}
EmptyBlockRule warns on empty code blocks.
type EmptyLinesRule ¶
type EmptyLinesRule struct{}
EmptyLinesRule lints empty lines in blocks.
type EnforceMapStyleRule ¶ added in v1.3.4
type EnforceMapStyleRule struct {
// contains filtered or unexported fields
}
EnforceMapStyleRule implements a rule to enforce `make(map[type]type)` over `map[type]type{}`.
func (*EnforceMapStyleRule) Configure ¶ added in v1.6.0
func (r *EnforceMapStyleRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*EnforceMapStyleRule) Name ¶ added in v1.3.4
func (*EnforceMapStyleRule) Name() string
Name returns the rule name.
type EnforceRepeatedArgTypeStyleRule ¶ added in v1.3.5
type EnforceRepeatedArgTypeStyleRule struct {
// contains filtered or unexported fields
}
EnforceRepeatedArgTypeStyleRule implements a rule to enforce repeated argument type style.
func (*EnforceRepeatedArgTypeStyleRule) Apply ¶ added in v1.3.5
Apply applies the rule to a given file.
func (*EnforceRepeatedArgTypeStyleRule) Configure ¶ added in v1.6.0
func (r *EnforceRepeatedArgTypeStyleRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*EnforceRepeatedArgTypeStyleRule) Name ¶ added in v1.3.5
func (*EnforceRepeatedArgTypeStyleRule) Name() string
Name returns the name of the linter rule.
type EnforceSliceStyleRule ¶ added in v1.3.5
type EnforceSliceStyleRule struct {
// contains filtered or unexported fields
}
EnforceSliceStyleRule implements a rule to enforce `make([]type)` over `[]type{}`.
func (*EnforceSliceStyleRule) Configure ¶ added in v1.6.0
func (r *EnforceSliceStyleRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*EnforceSliceStyleRule) Name ¶ added in v1.3.5
func (*EnforceSliceStyleRule) Name() string
Name returns the rule name.
type EnforceSwitchStyleRule ¶ added in v1.11.0
type EnforceSwitchStyleRule struct {
// contains filtered or unexported fields
}
EnforceSwitchStyleRule implements a rule to enforce default clauses use and/or position.
func (*EnforceSwitchStyleRule) Configure ¶ added in v1.11.0
func (r *EnforceSwitchStyleRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*EnforceSwitchStyleRule) Name ¶ added in v1.11.0
func (*EnforceSwitchStyleRule) Name() string
Name returns the rule name.
type ErrorNamingRule ¶
type ErrorNamingRule struct{}
ErrorNamingRule lints naming of error variables.
type ErrorReturnRule ¶
type ErrorReturnRule struct{}
ErrorReturnRule ensures that the error return parameter is the last parameter.
type ErrorStringsRule ¶
type ErrorStringsRule struct {
// contains filtered or unexported fields
}
ErrorStringsRule lints error strings.
func (*ErrorStringsRule) Configure ¶ added in v1.6.0
func (r *ErrorStringsRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
type ErrorfRule ¶
type ErrorfRule struct{}
ErrorfRule suggests using `fmt.Errorf` instead of `errors.New(fmt.Sprintf())`.
type ExportedRule ¶
type ExportedRule struct {
// contains filtered or unexported fields
}
ExportedRule lints naming and commenting conventions on exported symbols.
func (*ExportedRule) Configure ¶ added in v1.6.0
func (r *ExportedRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configure makes the rule implement the lint.ConfigurableRule interface.
type FileHeaderRule ¶
type FileHeaderRule struct {
// contains filtered or unexported fields
}
FileHeaderRule lints the header that each file should have.
func (*FileHeaderRule) Configure ¶ added in v1.6.0
func (r *FileHeaderRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
type FileLengthLimitRule ¶ added in v1.5.0
type FileLengthLimitRule struct {
// contains filtered or unexported fields
}
FileLengthLimitRule lints the number of lines in a file.
func (*FileLengthLimitRule) Configure ¶ added in v1.6.0
func (r *FileLengthLimitRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*FileLengthLimitRule) Name ¶ added in v1.5.0
func (*FileLengthLimitRule) Name() string
Name returns the rule name.
type FilenameFormatRule ¶ added in v1.5.0
type FilenameFormatRule struct {
// contains filtered or unexported fields
}
FilenameFormatRule lints source filenames according to a set of regular expressions given as arguments.
func (*FilenameFormatRule) Configure ¶ added in v1.6.0
func (r *FilenameFormatRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*FilenameFormatRule) Name ¶ added in v1.5.0
func (*FilenameFormatRule) Name() string
Name returns the rule name.
type FlagParamRule ¶
type FlagParamRule struct{}
FlagParamRule warns on boolean parameters that create a control coupling.
type ForbiddenCallInWgGoRule ¶ added in v1.13.0
type ForbiddenCallInWgGoRule struct{}
ForbiddenCallInWgGoRule spots calls to panic or wg.Done when using WaitGroup.Go.
func (*ForbiddenCallInWgGoRule) Name ¶ added in v1.13.0
func (*ForbiddenCallInWgGoRule) Name() string
Name returns the rule name.
type FunctionLength ¶ added in v1.0.5
type FunctionLength struct {
// contains filtered or unexported fields
}
FunctionLength lint.
func (*FunctionLength) Configure ¶ added in v1.6.0
func (r *FunctionLength) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*FunctionLength) Name ¶ added in v1.0.5
func (*FunctionLength) Name() string
Name returns the rule name.
type FunctionResultsLimitRule ¶
type FunctionResultsLimitRule struct {
// contains filtered or unexported fields
}
FunctionResultsLimitRule limits the maximum number of results a function can return.
func (*FunctionResultsLimitRule) Configure ¶ added in v1.6.0
func (r *FunctionResultsLimitRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*FunctionResultsLimitRule) Name ¶
func (*FunctionResultsLimitRule) Name() string
Name returns the rule name.
type GetReturnRule ¶
type GetReturnRule struct{}
GetReturnRule warns on getters that do not yield any result.
type IdenticalBranchesRule ¶ added in v1.0.3
type IdenticalBranchesRule struct{}
IdenticalBranchesRule warns on if...else statements with both branches being the same.
func (*IdenticalBranchesRule) Name ¶ added in v1.0.3
func (*IdenticalBranchesRule) Name() string
Name returns the rule name.
type IdenticalIfElseIfBranchesRule ¶ added in v1.12.0
type IdenticalIfElseIfBranchesRule struct{}
IdenticalIfElseIfBranchesRule warns on if...else if chains with identical branches.
func (*IdenticalIfElseIfBranchesRule) Apply ¶ added in v1.12.0
Apply applies the rule to given file.
func (*IdenticalIfElseIfBranchesRule) Name ¶ added in v1.12.0
func (*IdenticalIfElseIfBranchesRule) Name() string
Name returns the rule name.
type IdenticalIfElseIfConditionsRule ¶ added in v1.12.0
type IdenticalIfElseIfConditionsRule struct{}
IdenticalIfElseIfConditionsRule warns on if...else if chains with identical conditions.
func (*IdenticalIfElseIfConditionsRule) Apply ¶ added in v1.12.0
Apply applies the rule to given file.
func (*IdenticalIfElseIfConditionsRule) Name ¶ added in v1.12.0
func (*IdenticalIfElseIfConditionsRule) Name() string
Name returns the rule name.
type IdenticalSwitchBranchesRule ¶ added in v1.12.0
type IdenticalSwitchBranchesRule struct{}
IdenticalSwitchBranchesRule warns on identical switch branches.
func (*IdenticalSwitchBranchesRule) Name ¶ added in v1.12.0
func (*IdenticalSwitchBranchesRule) Name() string
Name returns the rule name.
type IdenticalSwitchConditionsRule ¶ added in v1.12.0
type IdenticalSwitchConditionsRule struct{}
IdenticalSwitchConditionsRule warns on switch case clauses with identical conditions.
func (*IdenticalSwitchConditionsRule) Apply ¶ added in v1.12.0
Apply applies the rule to given file.
func (*IdenticalSwitchConditionsRule) Name ¶ added in v1.12.0
func (*IdenticalSwitchConditionsRule) Name() string
Name returns the rule name.
type IfReturnRule ¶
type IfReturnRule struct{}
IfReturnRule searches for redundant `if` when returning an error.
type ImportAliasNamingRule ¶ added in v1.3.4
type ImportAliasNamingRule struct {
// contains filtered or unexported fields
}
ImportAliasNamingRule lints import alias naming.
func (*ImportAliasNamingRule) Configure ¶ added in v1.6.0
func (r *ImportAliasNamingRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*ImportAliasNamingRule) Name ¶ added in v1.3.4
func (*ImportAliasNamingRule) Name() string
Name returns the rule name.
type ImportShadowingRule ¶
type ImportShadowingRule struct{}
ImportShadowingRule spots identifiers that shadow an import.
func (*ImportShadowingRule) Name ¶
func (*ImportShadowingRule) Name() string
Name returns the rule name.
type ImportsBlocklistRule ¶ added in v1.3.7
type ImportsBlocklistRule struct {
// contains filtered or unexported fields
}
ImportsBlocklistRule disallows importing the specified packages.
func (*ImportsBlocklistRule) Configure ¶ added in v1.6.0
func (r *ImportsBlocklistRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*ImportsBlocklistRule) Name ¶ added in v1.3.7
func (*ImportsBlocklistRule) Name() string
Name returns the rule name.
type IncrementDecrementRule ¶
type IncrementDecrementRule struct{}
IncrementDecrementRule lints `i += 1` and `i -= 1` constructs.
func (*IncrementDecrementRule) Name ¶
func (*IncrementDecrementRule) Name() string
Name returns the rule name.
type IndentErrorFlowRule ¶
type IndentErrorFlowRule struct {
// contains filtered or unexported fields
}
IndentErrorFlowRule prevents redundant else statements.
func (*IndentErrorFlowRule) Configure ¶ added in v1.8.0
func (e *IndentErrorFlowRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*IndentErrorFlowRule) Name ¶
func (*IndentErrorFlowRule) Name() string
Name returns the rule name.
type InefficientMapLookupRule ¶ added in v1.13.0
type InefficientMapLookupRule struct{}
InefficientMapLookupRule spots potential inefficient map lookups.
func (*InefficientMapLookupRule) Name ¶ added in v1.13.0
func (*InefficientMapLookupRule) Name() string
Name returns the rule name.
type LineLengthLimitRule ¶
type LineLengthLimitRule struct {
// contains filtered or unexported fields
}
LineLengthLimitRule lints number of characters in a line.
func (*LineLengthLimitRule) Configure ¶ added in v1.6.0
func (r *LineLengthLimitRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*LineLengthLimitRule) Name ¶
func (*LineLengthLimitRule) Name() string
Name returns the rule name.
type MaxControlNestingRule ¶ added in v1.3.7
type MaxControlNestingRule struct {
// contains filtered or unexported fields
}
MaxControlNestingRule sets restriction for maximum nesting of control structures.
func (*MaxControlNestingRule) Configure ¶ added in v1.6.0
func (r *MaxControlNestingRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*MaxControlNestingRule) Name ¶ added in v1.3.7
func (*MaxControlNestingRule) Name() string
Name returns the rule name.
type MaxPublicStructsRule ¶
type MaxPublicStructsRule struct {
// contains filtered or unexported fields
}
MaxPublicStructsRule lints the number of public structs in a file.
func (*MaxPublicStructsRule) Configure ¶ added in v1.6.0
func (r *MaxPublicStructsRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*MaxPublicStructsRule) Name ¶
func (*MaxPublicStructsRule) Name() string
Name returns the rule name.
type ModifiesParamRule ¶
type ModifiesParamRule struct{}
ModifiesParamRule warns on assignments to function parameters.
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 ¶ added in v1.0.8
type NestedStructs struct{}
NestedStructs lints nested structs.
func (*NestedStructs) Name ¶ added in v1.0.8
func (*NestedStructs) Name() string
Name returns the rule name.
type OptimizeOperandsOrderRule ¶ added in v1.1.3
type OptimizeOperandsOrderRule struct{}
OptimizeOperandsOrderRule checks inefficient conditional expressions.
func (*OptimizeOperandsOrderRule) Name ¶ added in v1.1.3
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 PackageDirectoryMismatchRule ¶ added in v1.12.0
type PackageDirectoryMismatchRule struct {
// contains filtered or unexported fields
}
PackageDirectoryMismatchRule detects when package name doesn't match directory name.
func (*PackageDirectoryMismatchRule) Apply ¶ added in v1.12.0
Apply applies the rule to the given file.
func (*PackageDirectoryMismatchRule) Configure ¶ added in v1.12.0
func (r *PackageDirectoryMismatchRule) Configure(arguments lint.Arguments) error
Configure the rule to exclude certain directories.
func (*PackageDirectoryMismatchRule) Name ¶ added in v1.12.0
func (*PackageDirectoryMismatchRule) Name() string
Name returns the rule name.
type RangeRule ¶
type RangeRule struct{}
RangeRule prevents redundant variables when iterating over a collection.
type RangeValAddress ¶ added in v1.0.2
type RangeValAddress struct{}
RangeValAddress warns if address of range value is used dangerously.
func (*RangeValAddress) Name ¶ added in v1.0.2
func (*RangeValAddress) Name() string
Name returns the rule name.
type RangeValInClosureRule ¶
type RangeValInClosureRule struct{}
RangeValInClosureRule warns if range value is used in a closure dispatched as goroutine.
func (*RangeValInClosureRule) Name ¶
func (*RangeValInClosureRule) Name() string
Name returns the rule name.
type ReceiverNamingRule ¶
type ReceiverNamingRule struct {
// contains filtered or unexported fields
}
ReceiverNamingRule lints a receiver name.
func (*ReceiverNamingRule) Configure ¶ added in v1.6.0
func (r *ReceiverNamingRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
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 RedundantBuildTagRule ¶ added in v1.6.0
type RedundantBuildTagRule struct{}
RedundantBuildTagRule lints the presence of redundant build tags.
func (*RedundantBuildTagRule) Apply ¶ added in v1.6.0
Apply triggers if an old build tag `// +build` is found after a new one `//go:build`. `//go:build` comments are automatically added by gofmt when Go 1.17+ is used. See https://pkg.go.dev/cmd/go#hdr-Build_constraints
func (*RedundantBuildTagRule) Name ¶ added in v1.6.0
func (*RedundantBuildTagRule) Name() string
Name returns the rule name.
type RedundantImportAlias ¶ added in v1.3.3
type RedundantImportAlias struct{}
RedundantImportAlias warns on import aliases matching the imported package name.
func (*RedundantImportAlias) Name ¶ added in v1.3.3
func (*RedundantImportAlias) Name() string
Name returns the rule name.
type RedundantTestMainExitRule ¶ added in v1.6.1
type RedundantTestMainExitRule struct{}
RedundantTestMainExitRule suggests removing Exit call in TestMain function for test files.
func (*RedundantTestMainExitRule) Name ¶ added in v1.6.1
func (*RedundantTestMainExitRule) Name() string
Name returns the rule name.
type StringFormatRule ¶ added in v1.0.7
type StringFormatRule struct {
// contains filtered or unexported fields
}
StringFormatRule lints strings and/or comments according to a set of regular expressions given as Arguments.
func (*StringFormatRule) Configure ¶ added in v1.8.0
func (r *StringFormatRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*StringFormatRule) Name ¶ added in v1.0.7
func (*StringFormatRule) Name() string
Name returns the rule name.
type StringOfIntRule ¶ added in v1.0.2
type StringOfIntRule struct{}
StringOfIntRule warns when logic expressions contains Boolean literals.
func (*StringOfIntRule) Name ¶ added in v1.0.2
func (*StringOfIntRule) Name() string
Name returns the rule name.
type StructTagRule ¶
type StructTagRule struct {
// contains filtered or unexported fields
}
StructTagRule lints struct tags.
func (*StructTagRule) Configure ¶ added in v1.6.0
func (r *StructTagRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
type SuperfluousElseRule ¶
type SuperfluousElseRule struct {
// contains filtered or unexported fields
}
SuperfluousElseRule lints given else constructs.
func (*SuperfluousElseRule) Configure ¶ added in v1.8.0
func (e *SuperfluousElseRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*SuperfluousElseRule) Name ¶
func (*SuperfluousElseRule) Name() string
Name returns the rule name.
type TimeDateRule ¶ added in v1.10.0
type TimeDateRule struct{}
TimeDateRule lints the way time.Date is used.
func (*TimeDateRule) Name ¶ added in v1.10.0
func (*TimeDateRule) Name() string
Name returns the rule name.
type TimeEqualRule ¶ added in v1.1.3
type TimeEqualRule struct{}
TimeEqualRule shows where "==" and "!=" used for equality check time.Time.
func (*TimeEqualRule) Name ¶ added in v1.1.3
func (*TimeEqualRule) Name() string
Name returns the rule name.
type TimeNamingRule ¶
type TimeNamingRule struct{}
TimeNamingRule lints the name of a time variable.
type UncheckedTypeAssertionRule ¶ added in v1.3.4
type UncheckedTypeAssertionRule struct {
// contains filtered or unexported fields
}
UncheckedTypeAssertionRule lints missing or ignored `ok`-value in dynamic type casts.
func (*UncheckedTypeAssertionRule) Configure ¶ added in v1.6.0
func (r *UncheckedTypeAssertionRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*UncheckedTypeAssertionRule) Name ¶ added in v1.3.4
func (*UncheckedTypeAssertionRule) Name() string
Name returns the rule name.
type UnconditionalRecursionRule ¶ added in v1.0.3
type UnconditionalRecursionRule struct{}
UnconditionalRecursionRule warns on function calls that will lead to infinite recursion.
func (*UnconditionalRecursionRule) Name ¶ added in v1.0.3
func (*UnconditionalRecursionRule) Name() string
Name returns the rule name.
type UnexportedNamingRule ¶ added in v1.0.3
type UnexportedNamingRule struct{}
UnexportedNamingRule lints wrongly named unexported symbols.
func (*UnexportedNamingRule) Name ¶ added in v1.0.3
func (*UnexportedNamingRule) Name() string
Name returns the rule name.
type UnexportedReturnRule ¶
type UnexportedReturnRule struct{}
UnexportedReturnRule warns when a public return is from unexported type.
func (*UnexportedReturnRule) Name ¶
func (*UnexportedReturnRule) Name() string
Name returns the rule name.
type UnhandledErrorRule ¶
type UnhandledErrorRule struct {
// contains filtered or unexported fields
}
UnhandledErrorRule warns on unhandled errors returned by function calls.
func (*UnhandledErrorRule) Configure ¶ added in v1.6.0
func (r *UnhandledErrorRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*UnhandledErrorRule) Name ¶
func (*UnhandledErrorRule) Name() string
Name returns the rule name.
type UnnecessaryFormatRule ¶ added in v1.10.0
type UnnecessaryFormatRule struct{}
UnnecessaryFormatRule spots calls to formatting functions without leveraging formatting directives.
func (*UnnecessaryFormatRule) Name ¶ added in v1.10.0
func (*UnnecessaryFormatRule) Name() string
Name returns the rule name.
type UnnecessaryIfRule ¶ added in v1.13.0
type UnnecessaryIfRule struct{}
UnnecessaryIfRule warns on if...else statements that can be replaced by simpler expressions.
func (*UnnecessaryIfRule) Name ¶ added in v1.13.0
func (*UnnecessaryIfRule) 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 UnsecureURLSchemeRule ¶ added in v1.12.0
type UnsecureURLSchemeRule struct{}
UnsecureURLSchemeRule checks if a file contains string literals with unsecure URL schemes (for example: http://... in place of https://...).
func (*UnsecureURLSchemeRule) Name ¶ added in v1.12.0
func (*UnsecureURLSchemeRule) Name() string
Name returns the rule name.
type UnusedParamRule ¶
type UnusedParamRule struct {
// contains filtered or unexported fields
}
UnusedParamRule lints unused params in functions.
func (*UnusedParamRule) Configure ¶ added in v1.6.0
func (r *UnusedParamRule) Configure(args lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
type UnusedReceiverRule ¶
type UnusedReceiverRule struct {
// contains filtered or unexported fields
}
UnusedReceiverRule lints unused receivers in functions.
func (*UnusedReceiverRule) Configure ¶ added in v1.6.0
func (r *UnusedReceiverRule) Configure(args lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
func (*UnusedReceiverRule) Name ¶
func (*UnusedReceiverRule) Name() string
Name returns the rule name.
type UseAnyRule ¶ added in v1.2.0
type UseAnyRule struct{}
UseAnyRule proposes to replace `interface{}` with its alias `any`.
func (*UseAnyRule) Name ¶ added in v1.2.0
func (*UseAnyRule) Name() string
Name returns the rule name.
type UseErrorsNewRule ¶ added in v1.6.0
type UseErrorsNewRule struct{}
UseErrorsNewRule spots calls to fmt.Errorf that can be replaced by errors.New.
func (*UseErrorsNewRule) Name ¶ added in v1.6.0
func (*UseErrorsNewRule) Name() string
Name returns the rule name.
type UseFmtPrintRule ¶ added in v1.10.0
type UseFmtPrintRule struct{}
UseFmtPrintRule lints calls to print and println.
func (*UseFmtPrintRule) Name ¶ added in v1.10.0
func (*UseFmtPrintRule) Name() string
Name returns the rule name.
type UseWaitGroupGoRule ¶ added in v1.12.0
type UseWaitGroupGoRule struct{}
UseWaitGroupGoRule spots Go idioms that might be rewritten using WaitGroup.Go.
func (*UseWaitGroupGoRule) Name ¶ added in v1.12.0
func (*UseWaitGroupGoRule) Name() string
Name returns the rule name.
type UselessBreak ¶ added in v1.1.0
type UselessBreak struct{}
UselessBreak lint rule.
func (*UselessBreak) Name ¶ added in v1.1.0
func (*UselessBreak) Name() string
Name returns the rule name.
type UselessFallthroughRule ¶ added in v1.12.0
type UselessFallthroughRule struct{}
UselessFallthroughRule warns on useless fallthroughs in switch case clauses.
func (*UselessFallthroughRule) Name ¶ added in v1.12.0
func (*UselessFallthroughRule) Name() string
Name returns the rule name.
type VarDeclarationsRule ¶
type VarDeclarationsRule struct{}
VarDeclarationsRule reduces redundancies around variable declaration.
func (*VarDeclarationsRule) Name ¶
func (*VarDeclarationsRule) Name() string
Name returns the rule name.
type VarNamingRule ¶
type VarNamingRule struct {
// contains filtered or unexported fields
}
VarNamingRule lints the name of a variable.
func (*VarNamingRule) Configure ¶ added in v1.6.0
func (r *VarNamingRule) Configure(arguments lint.Arguments) error
Configure validates the rule configuration, and configures the rule accordingly.
Configuration implements the lint.ConfigurableRule interface.
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
- enforce_switch_style.go
- error_naming.go
- error_return.go
- error_strings.go
- errorf.go
- exported.go
- file_header.go
- file_length_limit.go
- filename_format.go
- flag_param.go
- forbidden_call_in_wg_go.go
- function_length.go
- function_result_limit.go
- get_return.go
- identical_branches.go
- identical_ifelseif_branches.go
- identical_ifelseif_condition.go
- identical_switch_branches.go
- identical_switch_conditions.go
- if_return.go
- import_alias_naming.go
- import_shadowing.go
- imports_blocklist.go
- increment_decrement.go
- indent_error_flow.go
- inefficient_map_lookup.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
- package_directory_mismatch.go
- range.go
- range_val_address.go
- range_val_in_closure.go
- receiver_naming.go
- redefines_builtin_id.go
- redundant_build_tag.go
- redundant_import_alias.go
- redundant_test_main_exit.go
- string_format.go
- string_of_int.go
- struct_tag.go
- superfluous_else.go
- time_date.go
- time_equal.go
- time_naming.go
- unchecked_type_assertion.go
- unconditional_recursion.go
- unexported_naming.go
- unexported_return.go
- unhandled_error.go
- unnecessary_format.go
- unnecessary_if.go
- unnecessary_stmt.go
- unreachable_code.go
- unsecure_url_scheme.go
- unused_param.go
- unused_receiver.go
- use_any.go
- use_errors_new.go
- use_fmt_print.go
- use_waitgroup_go.go
- useless_break.go
- useless_fallthrough.go
- utils.go
- var_declarations.go
- var_naming.go
- waitgroup_by_value.go