From 0d057914044024bc8c500f8bdebf65c2be64f052 Mon Sep 17 00:00:00 2001 From: Ville Vesilehto Date: Sun, 21 Sep 2025 18:17:35 +0300 Subject: [PATCH] lint: enable nakedret (#7569) Replace naked returns with explicit return values to satisfy nakedret linter and improve readability. Signed-off-by: Ville Vesilehto --- .golangci.yml | 1 + plugin/file/tree/tree.go | 2 +- plugin/loadbalance/loadbalance_test.go | 2 +- plugin/rewrite/name.go | 2 +- plugin/template/setup.go | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2e9eb318d..a43a00d96 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,6 +13,7 @@ linters: - govet - ineffassign - intrange + - nakedret - nolintlint - prealloc - protogetter diff --git a/plugin/file/tree/tree.go b/plugin/file/tree/tree.go index a6caafe16..e69befabf 100644 --- a/plugin/file/tree/tree.go +++ b/plugin/file/tree/tree.go @@ -213,7 +213,7 @@ func (n *Node) insert(rr dns.RR) (root *Node, d int) { root = n - return + return root, d } // DeleteMin deletes the node with the minimum value in the tree. diff --git a/plugin/loadbalance/loadbalance_test.go b/plugin/loadbalance/loadbalance_test.go index c46d96842..02a984271 100644 --- a/plugin/loadbalance/loadbalance_test.go +++ b/plugin/loadbalance/loadbalance_test.go @@ -192,7 +192,7 @@ func countRecords(result []dns.RR) (cname int, address int, mx int, sorted bool) state = Any } } - return + return cname, address, mx, sorted } func handler() plugin.Handler { diff --git a/plugin/rewrite/name.go b/plugin/rewrite/name.go index 00f682ef9..42c0054a5 100644 --- a/plugin/rewrite/name.go +++ b/plugin/rewrite/name.go @@ -417,7 +417,7 @@ func parseAnswerRules(name string, args []string) (auto bool, rules ResponseRule if auto && nameRules > 0 { return false, nil, fmt.Errorf("auto name answer rule cannot be combined with explicit name anwer rules") } - return + return auto, rules, nil } // hasClosingDot returns true if s has a closing dot at the end. diff --git a/plugin/template/setup.go b/plugin/template/setup.go index 56058f032..cb2c706f1 100644 --- a/plugin/template/setup.go +++ b/plugin/template/setup.go @@ -158,5 +158,5 @@ func templateParse(c *caddy.Controller) (handler Handler, err error) { handler.Templates = append(handler.Templates, t) } - return + return handler, nil }