Skip to content

Commit

Permalink
cleanup functions declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
mfederowicz committed Dec 24, 2023
1 parent 24df8df commit d1ceb23
Show file tree
Hide file tree
Showing 43 changed files with 90 additions and 90 deletions.
4 changes: 2 additions & 2 deletions rule/function-length.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ func (r *FunctionLength) Apply(file *lint.File, arguments lint.Arguments) []lint
}

// Name returns the rule name.
func (*FunctionLength) Name() string {
func (r *FunctionLength) Name() string {
return "function-length"
}

const defaultFuncStmtsLimit = 50
const defaultFuncLinesLimit = 75

func (*FunctionLength) parseArguments(arguments lint.Arguments) (maxStmt, maxLines int64) {
func (r *FunctionLength) parseArguments(arguments lint.Arguments) (maxStmt, maxLines int64) {
if len(arguments) == 0 {
return defaultFuncStmtsLimit, defaultFuncLinesLimit
}
Expand Down
2 changes: 1 addition & 1 deletion rule/function-result-limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r *FunctionResultsLimitRule) Apply(file *lint.File, arguments lint.Argumen
}

// Name returns the rule name.
func (*FunctionResultsLimitRule) Name() string {
func (r *FunctionResultsLimitRule) Name() string {
return "function-result-limit"
}

Expand Down
4 changes: 2 additions & 2 deletions rule/get-return.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type GetReturnRule struct{}

// Apply applies the rule to given file.
func (*GetReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *GetReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

onFailure := func(failure lint.Failure) {
Expand All @@ -25,7 +25,7 @@ func (*GetReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
}

// Name returns the rule name.
func (*GetReturnRule) Name() string {
func (r *GetReturnRule) Name() string {
return "get-return"
}

Expand Down
6 changes: 3 additions & 3 deletions rule/identical-branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type IdenticalBranchesRule struct{}

// Apply applies the rule to given file.
func (*IdenticalBranchesRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *IdenticalBranchesRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

onFailure := func(failure lint.Failure) {
Expand All @@ -24,7 +24,7 @@ func (*IdenticalBranchesRule) Apply(file *lint.File, _ lint.Arguments) []lint.Fa
}

// Name returns the rule name.
func (*IdenticalBranchesRule) Name() string {
func (r *IdenticalBranchesRule) Name() string {
return "identical-branches"
}

Expand Down Expand Up @@ -57,7 +57,7 @@ func (w *lintIdenticalBranches) Visit(node ast.Node) ast.Visitor {
return w
}

func (lintIdenticalBranches) identicalBranches(branches []*ast.BlockStmt) bool {
func (w lintIdenticalBranches) identicalBranches(branches []*ast.BlockStmt) bool {
if len(branches) < 2 {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions rule/if-return.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type IfReturnRule struct{}

// Apply applies the rule to given file.
func (*IfReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *IfReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

onFailure := func(failure lint.Failure) {
Expand All @@ -26,7 +26,7 @@ func (*IfReturnRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
}

// Name returns the rule name.
func (*IfReturnRule) Name() string {
func (r *IfReturnRule) Name() string {
return "if-return"
}

Expand Down
2 changes: 1 addition & 1 deletion rule/import-alias-naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *ImportAliasNamingRule) Apply(file *lint.File, arguments lint.Arguments)
}

// Name returns the rule name.
func (*ImportAliasNamingRule) Name() string {
func (r *ImportAliasNamingRule) Name() string {
return "import-alias-naming"
}

Expand Down
4 changes: 2 additions & 2 deletions rule/import-shadowing.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type ImportShadowingRule struct{}

// Apply applies the rule to given file.
func (*ImportShadowingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *ImportShadowingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

importNames := map[string]struct{}{}
Expand All @@ -38,7 +38,7 @@ func (*ImportShadowingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Fail
}

// Name returns the rule name.
func (*ImportShadowingRule) Name() string {
func (r *ImportShadowingRule) Name() string {
return "import-shadowing"
}

Expand Down
2 changes: 1 addition & 1 deletion rule/imports-blacklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ func (r *ImportsBlacklistRule) Apply(file *lint.File, arguments lint.Arguments)
}

// Name returns the rule name.
func (*ImportsBlacklistRule) Name() string {
func (r *ImportsBlacklistRule) Name() string {
return "imports-blacklist"
}
4 changes: 2 additions & 2 deletions rule/increment-decrement.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type IncrementDecrementRule struct{}

// Apply applies the rule to given file.
func (*IncrementDecrementRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *IncrementDecrementRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

fileAst := file.AST
Expand All @@ -29,7 +29,7 @@ func (*IncrementDecrementRule) Apply(file *lint.File, _ lint.Arguments) []lint.F
}

// Name returns the rule name.
func (*IncrementDecrementRule) Name() string {
func (r *IncrementDecrementRule) Name() string {
return "increment-decrement"
}

Expand Down
8 changes: 4 additions & 4 deletions rule/indent-error-flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import (
type IndentErrorFlowRule struct{}

// Apply applies the rule to given file.
func (e *IndentErrorFlowRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure {
return ifelse.Apply(e, file.AST, ifelse.TargetElse, args)
func (r *IndentErrorFlowRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure {
return ifelse.Apply(r, file.AST, ifelse.TargetElse, args)
}

// Name returns the rule name.
func (*IndentErrorFlowRule) Name() string {
func (r *IndentErrorFlowRule) Name() string {
return "indent-error-flow"
}

// CheckIfElse evaluates the rule against an ifelse.Chain.
func (*IndentErrorFlowRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) {
func (r *IndentErrorFlowRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) {
if !chain.If.Deviates() {
// this rule only applies if the if-block deviates control flow
return
Expand Down
2 changes: 1 addition & 1 deletion rule/line-length-limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (r *LineLengthLimitRule) Apply(file *lint.File, arguments lint.Arguments) [
}

// Name returns the rule name.
func (*LineLengthLimitRule) Name() string {
func (r *LineLengthLimitRule) Name() string {
return "line-length-limit"
}

Expand Down
2 changes: 1 addition & 1 deletion rule/max-public-structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r *MaxPublicStructsRule) Apply(file *lint.File, arguments lint.Arguments)
}

// Name returns the rule name.
func (*MaxPublicStructsRule) Name() string {
func (r *MaxPublicStructsRule) Name() string {
return "max-public-structs"
}

Expand Down
4 changes: 2 additions & 2 deletions rule/modifies-param.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type ModifiesParamRule struct{}

// Apply applies the rule to given file.
func (*ModifiesParamRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *ModifiesParamRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

onFailure := func(failure lint.Failure) {
Expand All @@ -24,7 +24,7 @@ func (*ModifiesParamRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failur
}

// Name returns the rule name.
func (*ModifiesParamRule) Name() string {
func (r *ModifiesParamRule) Name() string {
return "modifies-parameter"
}

Expand Down
6 changes: 3 additions & 3 deletions rule/modifies-value-receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type ModifiesValRecRule struct{}

// Apply applies the rule to given file.
func (*ModifiesValRecRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *ModifiesValRecRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

onFailure := func(failure lint.Failure) {
Expand All @@ -26,7 +26,7 @@ func (*ModifiesValRecRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failu
}

// Name returns the rule name.
func (*ModifiesValRecRule) Name() string {
func (r *ModifiesValRecRule) Name() string {
return "modifies-value-receiver"
}

Expand Down Expand Up @@ -119,7 +119,7 @@ func (w lintModifiesValRecRule) skipType(t ast.Expr) bool {
return strings.HasPrefix(rtName, "[]") || strings.HasPrefix(rtName, "map[")
}

func (lintModifiesValRecRule) getNameFromExpr(ie ast.Expr) string {
func (w lintModifiesValRecRule) getNameFromExpr(ie ast.Expr) string {
ident, ok := ie.(*ast.Ident)
if !ok {
return ""
Expand Down
4 changes: 2 additions & 2 deletions rule/nested-structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
type NestedStructs struct{}

// Apply applies the rule to given file.
func (*NestedStructs) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *NestedStructs) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

walker := &lintNestedStructs{
Expand All @@ -25,7 +25,7 @@ func (*NestedStructs) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
}

// Name returns the rule name.
func (*NestedStructs) Name() string {
func (r *NestedStructs) Name() string {
return "nested-structs"
}

Expand Down
4 changes: 2 additions & 2 deletions rule/optimize-operands-order.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type OptimizeOperandsOrderRule struct{}

// Apply applies the rule to given file.
func (*OptimizeOperandsOrderRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *OptimizeOperandsOrderRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

onFailure := func(failure lint.Failure) {
Expand All @@ -26,7 +26,7 @@ func (*OptimizeOperandsOrderRule) Apply(file *lint.File, _ lint.Arguments) []lin
}

// Name returns the rule name.
func (*OptimizeOperandsOrderRule) Name() string {
func (r *OptimizeOperandsOrderRule) Name() string {
return "optimize-operands-order"
}

Expand Down
2 changes: 1 addition & 1 deletion rule/package-comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (r *PackageCommentsRule) Apply(file *lint.File, _ lint.Arguments) []lint.Fa
}

// Name returns the rule name.
func (*PackageCommentsRule) Name() string {
func (r *PackageCommentsRule) Name() string {
return "package-comments"
}

Expand Down
4 changes: 2 additions & 2 deletions rule/range-val-address.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type RangeValAddress struct{}

// Apply applies the rule to given file.
func (*RangeValAddress) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *RangeValAddress) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

walker := rangeValAddress{
Expand All @@ -30,7 +30,7 @@ func (*RangeValAddress) Apply(file *lint.File, _ lint.Arguments) []lint.Failure
}

// Name returns the rule name.
func (*RangeValAddress) Name() string {
func (r *RangeValAddress) Name() string {
return "range-val-address"
}

Expand Down
4 changes: 2 additions & 2 deletions rule/range-val-in-closure.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type RangeValInClosureRule struct{}

// Apply applies the rule to given file.
func (*RangeValInClosureRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *RangeValInClosureRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

walker := rangeValInClosure{
Expand All @@ -26,7 +26,7 @@ func (*RangeValInClosureRule) Apply(file *lint.File, _ lint.Arguments) []lint.Fa
}

// Name returns the rule name.
func (*RangeValInClosureRule) Name() string {
func (r *RangeValInClosureRule) Name() string {
return "range-val-in-closure"
}

Expand Down
4 changes: 2 additions & 2 deletions rule/range.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type RangeRule struct{}

// Apply applies the rule to given file.
func (*RangeRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *RangeRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

onFailure := func(failure lint.Failure) {
Expand All @@ -25,7 +25,7 @@ func (*RangeRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
}

// Name returns the rule name.
func (*RangeRule) Name() string {
func (r *RangeRule) Name() string {
return "range"
}

Expand Down
4 changes: 2 additions & 2 deletions rule/receiver-naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type ReceiverNamingRule struct{}

// Apply applies the rule to given file.
func (*ReceiverNamingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *ReceiverNamingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

fileAst := file.AST
Expand All @@ -29,7 +29,7 @@ func (*ReceiverNamingRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failu
}

// Name returns the rule name.
func (*ReceiverNamingRule) Name() string {
func (r *ReceiverNamingRule) Name() string {
return "receiver-naming"
}

Expand Down
6 changes: 3 additions & 3 deletions rule/redefines-builtin-id.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var builtInTypes = map[string]bool{
type RedefinesBuiltinIDRule struct{}

// Apply applies the rule to given file.
func (*RedefinesBuiltinIDRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *RedefinesBuiltinIDRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

onFailure := func(failure lint.Failure) {
Expand All @@ -76,7 +76,7 @@ func (*RedefinesBuiltinIDRule) Apply(file *lint.File, _ lint.Arguments) []lint.F
}

// Name returns the rule name.
func (*RedefinesBuiltinIDRule) Name() string {
func (r *RedefinesBuiltinIDRule) Name() string {
return "redefines-builtin-id"
}

Expand Down Expand Up @@ -162,7 +162,7 @@ func (w lintRedefinesBuiltinID) addFailure(node ast.Node, msg string) {
})
}

func (lintRedefinesBuiltinID) isBuiltIn(id string) (r bool, builtInKind string) {
func (w lintRedefinesBuiltinID) isBuiltIn(id string) (r bool, builtInKind string) {
if builtFunctions[id] {
return true, "function"
}
Expand Down
4 changes: 2 additions & 2 deletions rule/redundant-import-alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
type RedundantImportAlias struct{}

// Apply applies the rule to given file.
func (*RedundantImportAlias) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
func (r *RedundantImportAlias) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
var failures []lint.Failure

for _, imp := range file.AST.Imports {
Expand All @@ -34,7 +34,7 @@ func (*RedundantImportAlias) Apply(file *lint.File, _ lint.Arguments) []lint.Fai
}

// Name returns the rule name.
func (*RedundantImportAlias) Name() string {
func (r *RedundantImportAlias) Name() string {
return "redundant-import-alias"
}

Expand Down
Loading

0 comments on commit d1ceb23

Please sign in to comment.