From: Anderson A. Giacomolli Date: Mon, 9 Nov 2026 21:03:33 +0000 (-0300) Subject: Separate returns from longer statement blocks X-Git-Url: https://git.giacomolli.uk/onechat/commitdiff_plain/a3b9849a54a6cd8a4cc5b1ae03a39aab31322f7b?ds=inline;hp=d9fddc0f506eb4ead7049f5638674b2b8773fcaa Separate returns from longer statement blocks Nlreturn checks spacing before returns and branch statements. Its short- block allowance keeps a declaration with its immediate use, as the Go rules require. Longer blocks have an empty line before they return or continue. --- diff --git a/.golangci.yml b/.golangci.yml index bba6f25..d5f20b3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,7 +8,11 @@ linters: - testifylint - revive - wrapcheck + - nlreturn settings: + nlreturn: + # go-code: Keep a short declaration with its immediate use. + block-size: 2 wrapcheck: # go-code: Return ctx.Err() directly. extra-ignore-sigs: diff --git a/whatsapp.go b/whatsapp.go index c3db573..b076708 100644 --- a/whatsapp.go +++ b/whatsapp.go @@ -459,6 +459,7 @@ func (w *WhatsApp) connect(ctx context.Context) bool { if err == nil || ctx.Err() != nil || !w.retrying || !w.linked { w.retrying = false w.mutex.Unlock() + return false } diff --git a/whatsapp_fake_helper_test.go b/whatsapp_fake_helper_test.go index 8e1da13..53fc0e8 100644 --- a/whatsapp_fake_helper_test.go +++ b/whatsapp_fake_helper_test.go @@ -105,6 +105,7 @@ func (f *WhatsAppFake) ConnectContext(ctx context.Context) error { if len(f.connectErrors) > 0 { err := f.connectErrors[0] f.connectErrors = f.connectErrors[1:] + return err } diff --git a/whatsapp_import.go b/whatsapp_import.go index 062d3ca..ef2bcba 100644 --- a/whatsapp_import.go +++ b/whatsapp_import.go @@ -530,6 +530,7 @@ func whatsappImportRead(path, owner string, location *time.Location) (chat Whats } messages[len(messages)-1].Text += "\n" + line + continue }