]> git.giacomolli.uk - onechat/commitdiff
Separate returns from longer statement blocks
authorAnderson A. Giacomolli <agiacomolli@gmail.com>
Mon, 9 Nov 2026 21:03:33 +0000 (18:03 -0300)
committerAnderson A. Giacomolli <agiacomolli@gmail.com>
Mon, 9 Nov 2026 21:28:42 +0000 (18:28 -0300)
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.

.golangci.yml
whatsapp.go
whatsapp_fake_helper_test.go
whatsapp_import.go

index bba6f25a3bcaf1190b09895e04be4d5af7fa99af..d5f20b34c84d8c768e034c4a208863b5f741e3a5 100644 (file)
@@ -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:
index c3db573f9c8d332ab885e662fd2b6e4e07b189f5..b0767084a6cb614af20f8dde1da27927f459aa50 100644 (file)
@@ -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
        }
 
index 8e1da1378ed81fe97f9dcab917f13843bb29dba9..53fc0e8b7a35b87dd42fbf751553a2c582688f4d 100644 (file)
@@ -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
        }
 
index 062d3cadd1bdc8c4772c134838f90d2e2abf8719..ef2bcbabd9cd4a7dc70b836448ff4e7553102e1b 100644 (file)
@@ -530,6 +530,7 @@ func whatsappImportRead(path, owner string, location *time.Location) (chat Whats
                        }
 
                        messages[len(messages)-1].Text += "\n" + line
+
                        continue
                }