Repository: mgechev/revive
Pull request #1147 (2024-11-28 22:23:08)

docs: fix rule descriptions
The PR fixes inaccurate rule comments. It appears that the descriptions were copied and pasted from the `SuperfluousElseRule`.


Patch:
diff --git a/README.md b/README.md
index 753b27f..823452f 100644
--- a/README.md
+++ b/README.md
@@ -655,7 +655,7 @@ With the snippet above we:
 - Enable the rule with the name `ban-struct-name`. The `Name()` method of our rule should return a string that matches `ban-struct-name`.
 - Configure the rule with the argument `Foo`. The list of arguments will be passed to `Apply(*File, Arguments)` together with the target file we're linting currently.
 
-A sample rule implementation can be found [here](/rule/argument-limit.go).
+A sample rule implementation can be found [here](/rule/argument_limit.go).
 
 #### Using `revive` as a library
 
diff --git a/rule/add_constant.go b/rule/add_constant.go
index bf822e7..5d7cd60 100644
--- a/rule/add_constant.go
+++ b/rule/add_constant.go
@@ -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 {
 	allowList       allowList
 	ignoreFunctions []*regexp.Regexp
diff --git a/rule/argument_limit.go b/rule/argument_limit.go
index b4d56de..ce831e5 100644
--- a/rule/argument_limit.go
+++ b/rule/argument_limit.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ArgumentsLimitRule lints given else constructs.
+// ArgumentsLimitRule lints the number of arguments a function can receive.
 type ArgumentsLimitRule struct {
 	max int
 
diff --git a/rule/atomic.go b/rule/atomic.go
index 287b28c..6121976 100644
--- a/rule/atomic.go
+++ b/rule/atomic.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// AtomicRule lints given else constructs.
+// AtomicRule lints usages of the `sync/atomic` package.
 type AtomicRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/bare_return.go b/rule/bare_return.go
index 147fa84..d81807b 100644
--- a/rule/bare_return.go
+++ b/rule/bare_return.go
@@ -6,7 +6,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// BareReturnRule lints given else constructs.
+// BareReturnRule lints bare returns.
 type BareReturnRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/blank_imports.go b/rule/blank_imports.go
index 10d84a4..f578ad3 100644
--- a/rule/blank_imports.go
+++ b/rule/blank_imports.go
@@ -7,7 +7,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// BlankImportsRule lints given else constructs.
+// BlankImportsRule lints blank imports.
 type BlankImportsRule struct{}
 
 // Name returns the rule name.
diff --git a/rule/cognitive_complexity.go b/rule/cognitive_complexity.go
index ecde388..e943207 100644
--- a/rule/cognitive_complexity.go
+++ b/rule/cognitive_complexity.go
@@ -10,7 +10,7 @@ import (
 	"golang.org/x/tools/go/ast/astutil"
 )
 
-// CognitiveComplexityRule lints given else constructs.
+// CognitiveComplexityRule sets restriction for maximum cognitive complexity.
 type CognitiveComplexityRule struct {
 	maxComplexity int
 
@@ -67,7 +67,9 @@ func (w cognitiveComplexityLinter) lintCognitiveComplexity() {
 	f := w.file
 	for _, decl := range f.AST.Decls {
 		if fn, ok := decl.(*ast.FuncDecl); ok && fn.Body != nil {
-			v := cognitiveComplexityVisitor{}
+			v := cognitiveComplexityVisitor{
+				name: fn.Name,
+			}
 			c := v.subTreeComplexity(fn.Body)
 			if c > w.maxComplexity {
 				w.onFailure(lint.Failure{
@@ -82,6 +84,7 @@ func (w cognitiveComplexityLinter) lintCognitiveComplexity() {
 }
 
 type cognitiveComplexityVisitor struct {
+	name         *ast.Ident
 	complexity   int
 	nestingLevel int
 }
@@ -125,8 +128,15 @@ func (v *cognitiveComplexityVisitor) Visit(n ast.Node) ast.Visitor {
 		if n.Label != nil {
 			v.complexity++
 		}
+	case *ast.CallExpr:
+		if ident, ok := n.Fun.(*ast.Ident); ok {
+			if ident.Obj == v.name.Obj && ident.Name == v.name.Name {
+				// called by same function directly (direct recursion)
+				v.complexity++
+				return nil
+			}
+		}
 	}
-	// TODO handle (at least) direct recursion
 
 	return v
 }
diff --git a/rule/comments_density.go b/rule/comments_density.go
index f2382b1..8cd4928 100644
--- a/rule/comments_density.go
+++ b/rule/comments_density.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// CommentsDensityRule lints given else constructs.
+// CommentsDensityRule enforces a minimum comment / code relation.
 type CommentsDensityRule struct {
 	minimumCommentsDensity int64
 
diff --git a/rule/context_as_argument.go b/rule/context_as_argument.go
index 8bc5f8b..06dc0f2 100644
--- a/rule/context_as_argument.go
+++ b/rule/context_as_argument.go
@@ -9,7 +9,7 @@ import (
 	"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 {
 	allowTypesLUT map[string]struct{}
 
diff --git a/rule/context_keys_type.go b/rule/context_keys_type.go
index 60ccec5..43369e7 100644
--- a/rule/context_keys_type.go
+++ b/rule/context_keys_type.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ContextKeysType lints given else constructs.
+// ContextKeysType disallows the usage of basic types in `context.WithValue`.
 type ContextKeysType struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/cyclomatic.go b/rule/cyclomatic.go
index c1a2de9..60f8441 100644
--- a/rule/cyclomatic.go
+++ b/rule/cyclomatic.go
@@ -11,7 +11,7 @@ import (
 
 // Based on https://github.com/fzipp/gocyclo
 
-// CyclomaticRule lints given else constructs.
+// CyclomaticRule sets restriction for maximum cyclomatic complexity.
 type CyclomaticRule struct {
 	maxComplexity int
 
diff --git a/rule/deep_exit.go b/rule/deep_exit.go
index ef81eb8..8441b50 100644
--- a/rule/deep_exit.go
+++ b/rule/deep_exit.go
@@ -17,7 +17,7 @@ func (*DeepExitRule) Apply(file *lint.File, _ lint.Arguments) []lint.Failure {
 		failures = append(failures, failure)
 	}
 
-	w := lintDeepExit{onFailure: onFailure, isTestFile: file.IsTest()}
+	w := &lintDeepExit{onFailure: onFailure, isTestFile: file.IsTest()}
 	ast.Walk(w, file.AST)
 	return failures
 }
@@ -32,7 +32,7 @@ type lintDeepExit struct {
 	isTestFile bool
 }
 
-func (w lintDeepExit) Visit(node ast.Node) ast.Visitor {
+func (w *lintDeepExit) Visit(node ast.Node) ast.Visitor {
 	if fd, ok := node.(*ast.FuncDecl); ok {
 		if w.mustIgnore(fd) {
 			return nil // skip analysis of this function
diff --git a/rule/defer.go b/rule/defer.go
index f7c716e..f6aae45 100644
--- a/rule/defer.go
+++ b/rule/defer.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// DeferRule lints unused params in functions.
+// DeferRule lints gotchas in defer statements.
 type DeferRule struct {
 	allow map[string]bool
 
diff --git a/rule/dot_imports.go b/rule/dot_imports.go
index 03deb4a..3bbd37c 100644
--- a/rule/dot_imports.go
+++ b/rule/dot_imports.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// DotImportsRule lints given else constructs.
+// DotImportsRule forbids . imports.
 type DotImportsRule struct {
 	allowedPackages allowPackages
 
diff --git a/rule/duplicated_imports.go b/rule/duplicated_imports.go
index 2b177fa..55ecb55 100644
--- a/rule/duplicated_imports.go
+++ b/rule/duplicated_imports.go
@@ -6,7 +6,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// DuplicatedImportsRule lints given else constructs.
+// DuplicatedImportsRule looks for packages that are imported two or more times.
 type DuplicatedImportsRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/empty_block.go b/rule/empty_block.go
index ba5652a..8d2d912 100644
--- a/rule/empty_block.go
+++ b/rule/empty_block.go
@@ -6,7 +6,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// EmptyBlockRule lints given else constructs.
+// EmptyBlockRule warns on empty code blocks.
 type EmptyBlockRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/error_naming.go b/rule/error_naming.go
index a4f24f3..e64fdf2 100644
--- a/rule/error_naming.go
+++ b/rule/error_naming.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ErrorNamingRule lints given else constructs.
+// ErrorNamingRule lints naming of error variables.
 type ErrorNamingRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/error_return.go b/rule/error_return.go
index a724e00..f26d807 100644
--- a/rule/error_return.go
+++ b/rule/error_return.go
@@ -6,7 +6,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ErrorReturnRule lints given else constructs.
+// ErrorReturnRule ensures that the error return parameter is the last parameter.
 type ErrorReturnRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/error_strings.go b/rule/error_strings.go
index 97a0f4d..a993368 100644
--- a/rule/error_strings.go
+++ b/rule/error_strings.go
@@ -12,7 +12,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ErrorStringsRule lints given else constructs.
+// ErrorStringsRule lints error strings.
 type ErrorStringsRule struct {
 	errorFunctions map[string]map[string]struct{}
 
diff --git a/rule/errorf.go b/rule/errorf.go
index 1588a74..228a3c7 100644
--- a/rule/errorf.go
+++ b/rule/errorf.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ErrorfRule lints given else constructs.
+// ErrorfRule suggests using `fmt.Errorf` instead of `errors.New(fmt.Sprintf())`.
 type ErrorfRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/exported.go b/rule/exported.go
index 1fdd4af..4bb56f4 100644
--- a/rule/exported.go
+++ b/rule/exported.go
@@ -62,7 +62,7 @@ var commonMethods = map[string]bool{
 	"Unwrap":    true,
 }
 
-// ExportedRule lints given else constructs.
+// ExportedRule lints naming and commenting conventions on exported symbols.
 type ExportedRule struct {
 	stuttersMsg    string
 	disabledChecks disabledChecks
diff --git a/rule/file_header.go b/rule/file_header.go
index 52513d8..a8c9ea2 100644
--- a/rule/file_header.go
+++ b/rule/file_header.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// FileHeaderRule lints given else constructs.
+// FileHeaderRule lints the header that each file should have.
 type FileHeaderRule struct {
 	header string
 
diff --git a/rule/flag_param.go b/rule/flag_param.go
index f9bfb71..8156121 100644
--- a/rule/flag_param.go
+++ b/rule/flag_param.go
@@ -7,7 +7,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// FlagParamRule lints given else constructs.
+// FlagParamRule warns on boolean parameters that create a control coupling.
 type FlagParamRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/function_result_limit.go b/rule/function_result_limit.go
index 5b72f01..bd4fe37 100644
--- a/rule/function_result_limit.go
+++ b/rule/function_result_limit.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// FunctionResultsLimitRule lints given else constructs.
+// FunctionResultsLimitRule limits the maximum number of results a function can return.
 type FunctionResultsLimitRule struct {
 	max int
 
diff --git a/rule/get_return.go b/rule/get_return.go
index 06323a0..638c202 100644
--- a/rule/get_return.go
+++ b/rule/get_return.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// GetReturnRule lints given else constructs.
+// GetReturnRule warns on getters that do not yield any result.
 type GetReturnRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/if_return.go b/rule/if_return.go
index a6a3113..f9e5ef2 100644
--- a/rule/if_return.go
+++ b/rule/if_return.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// IfReturnRule lints given else constructs.
+// IfReturnRule searches for redundant `if` when returning an error.
 type IfReturnRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/import_shadowing.go b/rule/import_shadowing.go
index 046aeb6..474d5b8 100644
--- a/rule/import_shadowing.go
+++ b/rule/import_shadowing.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ImportShadowingRule lints given else constructs.
+// ImportShadowingRule spots identifiers that shadow an import.
 type ImportShadowingRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/imports_blocklist.go b/rule/imports_blocklist.go
index 18d77ca..6ae8be1 100644
--- a/rule/imports_blocklist.go
+++ b/rule/imports_blocklist.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ImportsBlocklistRule lints given else constructs.
+// ImportsBlocklistRule disallows importing the specified packages.
 type ImportsBlocklistRule struct {
 	blocklist []*regexp.Regexp
 
diff --git a/rule/increment_decrement.go b/rule/increment_decrement.go
index 34a8e1e..8158cca 100644
--- a/rule/increment_decrement.go
+++ b/rule/increment_decrement.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// IncrementDecrementRule lints given else constructs.
+// IncrementDecrementRule lints `i += 1` and `i -= 1` constructs.
 type IncrementDecrementRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/indent_error_flow.go b/rule/indent_error_flow.go
index 2abbfbf..5e554d5 100644
--- a/rule/indent_error_flow.go
+++ b/rule/indent_error_flow.go
@@ -5,7 +5,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// IndentErrorFlowRule lints given else constructs.
+// IndentErrorFlowRule prevents redundant else statements.
 type IndentErrorFlowRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/line_length_limit.go b/rule/line_length_limit.go
index 415761e..dcac2ad 100644
--- a/rule/line_length_limit.go
+++ b/rule/line_length_limit.go
@@ -12,7 +12,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// LineLengthLimitRule lints given else constructs.
+// LineLengthLimitRule lints number of characters in a line.
 type LineLengthLimitRule struct {
 	max int
 
diff --git a/rule/max_control_nesting.go b/rule/max_control_nesting.go
index b2c5af7..2898af6 100644
--- a/rule/max_control_nesting.go
+++ b/rule/max_control_nesting.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// MaxControlNestingRule lints given else constructs.
+// MaxControlNestingRule sets restriction for maximum nesting of control structures.
 type MaxControlNestingRule struct {
 	max int64
 
diff --git a/rule/max_public_structs.go b/rule/max_public_structs.go
index d6f91e3..bbb2071 100644
--- a/rule/max_public_structs.go
+++ b/rule/max_public_structs.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// MaxPublicStructsRule lints given else constructs.
+// MaxPublicStructsRule lints the number of public structs in a file.
 type MaxPublicStructsRule struct {
 	max int64
 
diff --git a/rule/modifies_param.go b/rule/modifies_param.go
index a68ae25..caaebe6 100644
--- a/rule/modifies_param.go
+++ b/rule/modifies_param.go
@@ -7,7 +7,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ModifiesParamRule lints given else constructs.
+// ModifiesParamRule warns on assignments to function parameters.
 type ModifiesParamRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/optimize_operands_order.go b/rule/optimize_operands_order.go
index 43d982d..3c8f30f 100644
--- a/rule/optimize_operands_order.go
+++ b/rule/optimize_operands_order.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// OptimizeOperandsOrderRule lints given else constructs.
+// OptimizeOperandsOrderRule checks inefficient conditional expressions.
 type OptimizeOperandsOrderRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/range.go b/rule/range.go
index 9d483a6..b54078e 100644
--- a/rule/range.go
+++ b/rule/range.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// RangeRule lints given else constructs.
+// RangeRule prevents redundant variables when iterating over a collection.
 type RangeRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/range_val_in_closure.go b/rule/range_val_in_closure.go
index 6f9255a..9207828 100644
--- a/rule/range_val_in_closure.go
+++ b/rule/range_val_in_closure.go
@@ -7,7 +7,7 @@ import (
 	"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{}
 
 // Apply applies the rule to given file.
diff --git a/rule/receiver_naming.go b/rule/receiver_naming.go
index c83bacc..e1060a5 100644
--- a/rule/receiver_naming.go
+++ b/rule/receiver_naming.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// ReceiverNamingRule lints given else constructs.
+// ReceiverNamingRule lints a receiver name.
 type ReceiverNamingRule struct {
 	receiverNameMaxLength int
 
diff --git a/rule/redundant_import_alias.go b/rule/redundant_import_alias.go
index fa5281f..93f8936 100644
--- a/rule/redundant_import_alias.go
+++ b/rule/redundant_import_alias.go
@@ -8,7 +8,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// RedundantImportAlias lints given else constructs.
+// RedundantImportAlias warns on import aliases matching the imported package name.
 type RedundantImportAlias struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/time_naming.go b/rule/time_naming.go
index 5bccf8a..67e79ea 100644
--- a/rule/time_naming.go
+++ b/rule/time_naming.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// TimeNamingRule lints given else constructs.
+// TimeNamingRule lints the name of a time variable.
 type TimeNamingRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/unconditional_recursion.go b/rule/unconditional_recursion.go
index 271c3fa..9cdee38 100644
--- a/rule/unconditional_recursion.go
+++ b/rule/unconditional_recursion.go
@@ -6,7 +6,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// UnconditionalRecursionRule lints given else constructs.
+// UnconditionalRecursionRule warns on function calls that will lead to infinite recursion.
 type UnconditionalRecursionRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/unexported_return.go b/rule/unexported_return.go
index 10f8e3f..e2400af 100644
--- a/rule/unexported_return.go
+++ b/rule/unexported_return.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// UnexportedReturnRule lints given else constructs.
+// UnexportedReturnRule warns when a public return is from unexported type.
 type UnexportedReturnRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/unhandled_error.go b/rule/unhandled_error.go
index 4fad8cc..fabc4fb 100644
--- a/rule/unhandled_error.go
+++ b/rule/unhandled_error.go
@@ -11,7 +11,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// UnhandledErrorRule lints given else constructs.
+// UnhandledErrorRule warns on unhandled errors returned by function calls.
 type UnhandledErrorRule struct {
 	ignoreList []*regexp.Regexp
 
diff --git a/rule/unused_receiver.go b/rule/unused_receiver.go
index 131aae5..f1866cf 100644
--- a/rule/unused_receiver.go
+++ b/rule/unused_receiver.go
@@ -9,7 +9,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// UnusedReceiverRule lints unused params in functions.
+// UnusedReceiverRule lints unused receivers in functions.
 type UnusedReceiverRule struct {
 	// regex to check if some name is valid for unused parameter, "^_$" by default
 	allowRegex *regexp.Regexp
diff --git a/rule/use_any.go b/rule/use_any.go
index 88160c2..cd01d5b 100644
--- a/rule/use_any.go
+++ b/rule/use_any.go
@@ -6,7 +6,7 @@ import (
 	"github.com/mgechev/revive/lint"
 )
 
-// UseAnyRule lints given else constructs.
+// UseAnyRule proposes to replace `interface{}` with its alias `any`.
 type UseAnyRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/var_declarations.go b/rule/var_declarations.go
index 0186c3d..7d60efd 100644
--- a/rule/var_declarations.go
+++ b/rule/var_declarations.go
@@ -25,7 +25,7 @@ var zeroLiteral = map[string]bool{
 	"0i":  true,
 }
 
-// VarDeclarationsRule lints given else constructs.
+// VarDeclarationsRule reduces redundancies around variable declaration.
 type VarDeclarationsRule struct{}
 
 // Apply applies the rule to given file.
diff --git a/rule/var_naming.go b/rule/var_naming.go
index 61f621a..320eb39 100644
--- a/rule/var_naming.go
+++ b/rule/var_naming.go
@@ -23,7 +23,7 @@ var knownNameExceptions = map[string]bool{
 	"kWh":          true,
 }
 
-// VarNamingRule lints given else constructs.
+// VarNamingRule lints the name of a variable.
 type VarNamingRule struct {
 	allowList             []string
 	blockList             []string


Test patch:
diff --git a/testdata/cognitive_complexity.go b/testdata/cognitive_complexity.go
index c20794b..17fab4e 100644
--- a/testdata/cognitive_complexity.go
+++ b/testdata/cognitive_complexity.go
@@ -281,3 +281,13 @@ func (m *Migrator) MigrateIfNeeded(target *EtcdVersionPair) error { // MATCH /fu
 
 // no regression test for issue #451
 func myFunc()
+
+// Recursive functions
+func Walk(t *Tree, ch chan int) { // MATCH /function Walk has cognitive complexity 3 (> max enabled 0)/
+	if t == nil { // +1
+		return
+	}
+	Walk(t.Left, ch) // +1
+	ch <- t.Value
+	Walk(t.Right, ch) // +1
+}