From b625f09b6e7f1e376b164d20b0f3d68ac10f22b4 Mon Sep 17 00:00:00 2001 From: Marcin Federowicz Date: Sun, 24 Sep 2023 01:15:18 +0200 Subject: [PATCH 1/9] cleanup: rename unused parameters and receivers to _ --- revivelib/core_internal_test.go | 2 +- rule/add-constant.go | 2 +- rule/constant-logical-expr.go | 8 ++++---- rule/datarace.go | 2 +- rule/early-return.go | 2 +- rule/enforce-map-style.go | 2 +- rule/enforce-slice-style.go | 2 +- rule/indent-error-flow.go | 2 +- rule/superfluous-else.go | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/revivelib/core_internal_test.go b/revivelib/core_internal_test.go index 9c4ff877e..3de76435d 100644 --- a/revivelib/core_internal_test.go +++ b/revivelib/core_internal_test.go @@ -43,7 +43,7 @@ func (*mockRule) Name() string { return "mock-rule" } -func (*mockRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { +func (*mockRule) Apply(_ *lint.File, _ lint.Arguments) []lint.Failure { return nil } diff --git a/rule/add-constant.go b/rule/add-constant.go index 36a7003da..895bf7007 100644 --- a/rule/add-constant.go +++ b/rule/add-constant.go @@ -105,7 +105,7 @@ func (w lintAddConstantRule) checkFunc(expr *ast.CallExpr) { } } -func (w lintAddConstantRule) getFuncName(expr *ast.CallExpr) string { +func (_ lintAddConstantRule) getFuncName(expr *ast.CallExpr) string { switch f := expr.Fun.(type) { case *ast.SelectorExpr: switch prefix := f.X.(type) { diff --git a/rule/constant-logical-expr.go b/rule/constant-logical-expr.go index 9abc95d67..5a59fadf5 100644 --- a/rule/constant-logical-expr.go +++ b/rule/constant-logical-expr.go @@ -11,7 +11,7 @@ import ( type ConstantLogicalExprRule struct{} // Apply applies the rule to given file. -func (r *ConstantLogicalExprRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { +func (_ *ConstantLogicalExprRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { var failures []lint.Failure onFailure := func(failure lint.Failure) { @@ -63,7 +63,7 @@ func (w *lintConstantLogicalExpr) Visit(node ast.Node) ast.Visitor { return w } -func (w *lintConstantLogicalExpr) isOperatorWithLogicalResult(t token.Token) bool { +func (_ *lintConstantLogicalExpr) isOperatorWithLogicalResult(t token.Token) bool { switch t { case token.LAND, token.LOR, token.EQL, token.LSS, token.GTR, token.NEQ, token.LEQ, token.GEQ: return true @@ -72,7 +72,7 @@ func (w *lintConstantLogicalExpr) isOperatorWithLogicalResult(t token.Token) boo return false } -func (w *lintConstantLogicalExpr) isEqualityOperator(t token.Token) bool { +func (_ *lintConstantLogicalExpr) isEqualityOperator(t token.Token) bool { switch t { case token.EQL, token.LEQ, token.GEQ: return true @@ -81,7 +81,7 @@ func (w *lintConstantLogicalExpr) isEqualityOperator(t token.Token) bool { return false } -func (w *lintConstantLogicalExpr) isInequalityOperator(t token.Token) bool { +func (_ *lintConstantLogicalExpr) isInequalityOperator(t token.Token) bool { switch t { case token.LSS, token.GTR, token.NEQ: return true diff --git a/rule/datarace.go b/rule/datarace.go index 26fcadcdc..5636aee62 100644 --- a/rule/datarace.go +++ b/rule/datarace.go @@ -53,7 +53,7 @@ func (w lintDataRaces) Visit(n ast.Node) ast.Visitor { return nil } -func (w lintDataRaces) ExtractReturnIDs(fields []*ast.Field) map[*ast.Object]struct{} { +func (_ lintDataRaces) ExtractReturnIDs(fields []*ast.Field) map[*ast.Object]struct{} { r := map[*ast.Object]struct{}{} for _, f := range fields { for _, id := range f.Names { diff --git a/rule/early-return.go b/rule/early-return.go index 90a0acc55..78504040a 100644 --- a/rule/early-return.go +++ b/rule/early-return.go @@ -22,7 +22,7 @@ func (*EarlyReturnRule) Name() string { } // CheckIfElse evaluates the rule against an ifelse.Chain. -func (e *EarlyReturnRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) { +func (_ *EarlyReturnRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) { if !chain.Else.Deviates() { // this rule only applies if the else-block deviates control flow return diff --git a/rule/enforce-map-style.go b/rule/enforce-map-style.go index ae27b654f..bcdcfd7c7 100644 --- a/rule/enforce-map-style.go +++ b/rule/enforce-map-style.go @@ -141,7 +141,7 @@ func (r *EnforceMapStyleRule) Apply(file *lint.File, arguments lint.Arguments) [ } // Name returns the rule name. -func (r *EnforceMapStyleRule) Name() string { +func (_ *EnforceMapStyleRule) Name() string { return "enforce-map-style" } diff --git a/rule/enforce-slice-style.go b/rule/enforce-slice-style.go index b3611d51a..a5ed07c75 100644 --- a/rule/enforce-slice-style.go +++ b/rule/enforce-slice-style.go @@ -165,7 +165,7 @@ func (r *EnforceSliceStyleRule) Apply(file *lint.File, arguments lint.Arguments) } // Name returns the rule name. -func (r *EnforceSliceStyleRule) Name() string { +func (_ *EnforceSliceStyleRule) Name() string { return "enforce-slice-style" } diff --git a/rule/indent-error-flow.go b/rule/indent-error-flow.go index b80e6486c..44998d696 100644 --- a/rule/indent-error-flow.go +++ b/rule/indent-error-flow.go @@ -19,7 +19,7 @@ func (*IndentErrorFlowRule) Name() string { } // CheckIfElse evaluates the rule against an ifelse.Chain. -func (e *IndentErrorFlowRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) { +func (_ *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 diff --git a/rule/superfluous-else.go b/rule/superfluous-else.go index 1ef67bf1a..207882782 100644 --- a/rule/superfluous-else.go +++ b/rule/superfluous-else.go @@ -20,7 +20,7 @@ func (*SuperfluousElseRule) Name() string { } // CheckIfElse evaluates the rule against an ifelse.Chain. -func (e *SuperfluousElseRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) { +func (_ *SuperfluousElseRule) 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 From da9c76c0f40a8fd7ec055802b5497ececdb596d3 Mon Sep 17 00:00:00 2001 From: chavacava Date: Sun, 24 Sep 2023 08:47:15 +0200 Subject: [PATCH 2/9] removes unused receiver --- rule/add-constant.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule/add-constant.go b/rule/add-constant.go index 895bf7007..adbbbd6ba 100644 --- a/rule/add-constant.go +++ b/rule/add-constant.go @@ -105,7 +105,7 @@ func (w lintAddConstantRule) checkFunc(expr *ast.CallExpr) { } } -func (_ lintAddConstantRule) getFuncName(expr *ast.CallExpr) string { +func (lintAddConstantRule) getFuncName(expr *ast.CallExpr) string { switch f := expr.Fun.(type) { case *ast.SelectorExpr: switch prefix := f.X.(type) { From 6e43c95df0c4e0b2f72f7bcd26556f29fa06141d Mon Sep 17 00:00:00 2001 From: chavacava Date: Sun, 24 Sep 2023 08:48:38 +0200 Subject: [PATCH 3/9] removes unused receiver --- rule/constant-logical-expr.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rule/constant-logical-expr.go b/rule/constant-logical-expr.go index 5a59fadf5..36cd641f7 100644 --- a/rule/constant-logical-expr.go +++ b/rule/constant-logical-expr.go @@ -11,7 +11,7 @@ import ( type ConstantLogicalExprRule struct{} // Apply applies the rule to given file. -func (_ *ConstantLogicalExprRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { +func (*ConstantLogicalExprRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure { var failures []lint.Failure onFailure := func(failure lint.Failure) { @@ -63,7 +63,7 @@ func (w *lintConstantLogicalExpr) Visit(node ast.Node) ast.Visitor { return w } -func (_ *lintConstantLogicalExpr) isOperatorWithLogicalResult(t token.Token) bool { +func (*lintConstantLogicalExpr) isOperatorWithLogicalResult(t token.Token) bool { switch t { case token.LAND, token.LOR, token.EQL, token.LSS, token.GTR, token.NEQ, token.LEQ, token.GEQ: return true @@ -72,7 +72,7 @@ func (_ *lintConstantLogicalExpr) isOperatorWithLogicalResult(t token.Token) boo return false } -func (_ *lintConstantLogicalExpr) isEqualityOperator(t token.Token) bool { +func (*lintConstantLogicalExpr) isEqualityOperator(t token.Token) bool { switch t { case token.EQL, token.LEQ, token.GEQ: return true @@ -81,7 +81,7 @@ func (_ *lintConstantLogicalExpr) isEqualityOperator(t token.Token) bool { return false } -func (_ *lintConstantLogicalExpr) isInequalityOperator(t token.Token) bool { +func (*lintConstantLogicalExpr) isInequalityOperator(t token.Token) bool { switch t { case token.LSS, token.GTR, token.NEQ: return true From aa2a5eb5a1ffd481e057d68795d4849d5c899498 Mon Sep 17 00:00:00 2001 From: chavacava Date: Sun, 24 Sep 2023 08:49:14 +0200 Subject: [PATCH 4/9] removes unused receiver --- rule/datarace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule/datarace.go b/rule/datarace.go index 5636aee62..c8754ea65 100644 --- a/rule/datarace.go +++ b/rule/datarace.go @@ -53,7 +53,7 @@ func (w lintDataRaces) Visit(n ast.Node) ast.Visitor { return nil } -func (_ lintDataRaces) ExtractReturnIDs(fields []*ast.Field) map[*ast.Object]struct{} { +func (lintDataRaces) ExtractReturnIDs(fields []*ast.Field) map[*ast.Object]struct{} { r := map[*ast.Object]struct{}{} for _, f := range fields { for _, id := range f.Names { From e8b3ab47b7a3d4db2eb6bfd132af174ef2fa2e39 Mon Sep 17 00:00:00 2001 From: chavacava Date: Sun, 24 Sep 2023 08:49:55 +0200 Subject: [PATCH 5/9] removes unused receiver --- rule/early-return.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule/early-return.go b/rule/early-return.go index 78504040a..9c04a1dbe 100644 --- a/rule/early-return.go +++ b/rule/early-return.go @@ -22,7 +22,7 @@ func (*EarlyReturnRule) Name() string { } // CheckIfElse evaluates the rule against an ifelse.Chain. -func (_ *EarlyReturnRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) { +func (*EarlyReturnRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) { if !chain.Else.Deviates() { // this rule only applies if the else-block deviates control flow return From a6df12abb18c484c6110fcb8fb2d726c03fb6d14 Mon Sep 17 00:00:00 2001 From: chavacava Date: Sun, 24 Sep 2023 08:50:28 +0200 Subject: [PATCH 6/9] removes unused receiver --- rule/enforce-map-style.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule/enforce-map-style.go b/rule/enforce-map-style.go index bcdcfd7c7..d584434ce 100644 --- a/rule/enforce-map-style.go +++ b/rule/enforce-map-style.go @@ -141,7 +141,7 @@ func (r *EnforceMapStyleRule) Apply(file *lint.File, arguments lint.Arguments) [ } // Name returns the rule name. -func (_ *EnforceMapStyleRule) Name() string { +func (*EnforceMapStyleRule) Name() string { return "enforce-map-style" } From 9715177af26e9720547083fba298b5db0b19b8c2 Mon Sep 17 00:00:00 2001 From: chavacava Date: Sun, 24 Sep 2023 08:51:03 +0200 Subject: [PATCH 7/9] removes unused receiver --- rule/enforce-slice-style.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule/enforce-slice-style.go b/rule/enforce-slice-style.go index a5ed07c75..abaf20be0 100644 --- a/rule/enforce-slice-style.go +++ b/rule/enforce-slice-style.go @@ -165,7 +165,7 @@ func (r *EnforceSliceStyleRule) Apply(file *lint.File, arguments lint.Arguments) } // Name returns the rule name. -func (_ *EnforceSliceStyleRule) Name() string { +func (*EnforceSliceStyleRule) Name() string { return "enforce-slice-style" } From 2ede21e8503bb0b0bb924322e6f81f9912e6f35a Mon Sep 17 00:00:00 2001 From: chavacava Date: Sun, 24 Sep 2023 08:51:42 +0200 Subject: [PATCH 8/9] Update indent-error-flow.go --- rule/indent-error-flow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule/indent-error-flow.go b/rule/indent-error-flow.go index 44998d696..294ceef84 100644 --- a/rule/indent-error-flow.go +++ b/rule/indent-error-flow.go @@ -19,7 +19,7 @@ func (*IndentErrorFlowRule) Name() string { } // CheckIfElse evaluates the rule against an ifelse.Chain. -func (_ *IndentErrorFlowRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) { +func (*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 From 7aadd1788e81cb19de5963687eff9593f0ad47f6 Mon Sep 17 00:00:00 2001 From: chavacava Date: Sun, 24 Sep 2023 08:52:12 +0200 Subject: [PATCH 9/9] removes unused receiver --- rule/superfluous-else.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rule/superfluous-else.go b/rule/superfluous-else.go index 207882782..2aa1b6b2c 100644 --- a/rule/superfluous-else.go +++ b/rule/superfluous-else.go @@ -20,7 +20,7 @@ func (*SuperfluousElseRule) Name() string { } // CheckIfElse evaluates the rule against an ifelse.Chain. -func (_ *SuperfluousElseRule) CheckIfElse(chain ifelse.Chain, args ifelse.Args) (failMsg string) { +func (*SuperfluousElseRule) 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