From 1c8243cc9540dff6d0d3e6d007eccf155d6e5bbd Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 18 Feb 2025 09:35:30 +0100 Subject: [PATCH] golangci-lint: fix invalid nakedret config, disallow for any func length The regex was added before we migrateed from gometalinter in dbd96badb6959c2b7070664aecbcf0f7c299c538, and got migrated to golangci-lint in b7e06f2845bb4996269a49f2592a735e4cd03e49. The format used for the config was invalid, and migrating it to the right format didn't make a difference, so we can remove it. As naked returns are generally not desirable, also setting the minimum func length to 0 (i.e., don't allow any naked returns), instead of the default Signed-off-by: Sebastiaan van Stijn --- .golangci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fc4d8b48df..aa54d46c9b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -17,7 +17,7 @@ linters: - ineffassign - lll - misspell # Detects commonly misspelled English words in comments. - - nakedret + - nakedret # Detects uses of naked returns. - nilerr # Detects code that returns nil even if it checks that the error is not nil. - nolintlint # Detects ill-formed or insufficient nolint directives. - perfsprint # Detects fmt.Sprintf uses that can be replaced with a faster alternative. @@ -81,8 +81,9 @@ linters-settings: lll: line-length: 200 nakedret: - command: nakedret - pattern: ^(?P.*?\\.go):(?P\\d+)\\s*(?P.*)$ + # Disallow naked returns if func has more lines of code than this setting. + # Default: 30 + max-func-lines: 0 revive: rules: