1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

Minor cleanups for staticcheck issues

staticcheck found a couple of minor code cleanup improvements, like
unused variables or an out-of-order defer, mostly in tests.

This patch fixes those problems by making the necessary adjustments.

They're all fairly small, and should not change the logic in any
significant way.
This commit is contained in:
Alberto Bertogli
2025-10-24 12:00:18 +01:00
parent 7a4a4e4b34
commit f7e0e9fe65
5 changed files with 6 additions and 10 deletions

View File

@@ -3,8 +3,6 @@ package dkim
import (
"context"
"crypto"
"crypto/ed25519"
"crypto/x509"
"encoding/base64"
"errors"
"testing"
@@ -36,7 +34,6 @@ const exampleRSAKeyB64 = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQ" +
"tdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB"
var exampleRSAKeyBuf, _ = base64.StdEncoding.DecodeString(exampleRSAKeyB64)
var exampleRSAKey, _ = x509.ParsePKCS1PublicKey(exampleRSAKeyBuf)
// Ed25519 key from the RFC example.
// https://datatracker.ietf.org/doc/html/rfc8463#appendix-A.2
@@ -44,7 +41,6 @@ const exampleEd25519KeyB64 = "11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo="
var exampleEd25519KeyBuf, _ = base64.StdEncoding.DecodeString(
exampleEd25519KeyB64)
var exampleEd25519Key = ed25519.PublicKey(exampleEd25519KeyBuf)
var results = map[string][]string{}
var resultErr = map[string]error{}

View File

@@ -22,10 +22,10 @@ func Hola(tr *trace.Trace, input url.Values) (url.Values, error) {
return output, nil
}
var testErr = errors.New("test error")
var errTest = errors.New("test error")
func HolaErr(tr *trace.Trace, input url.Values) (url.Values, error) {
return nil, testErr
return nil, errTest
}
type testServer struct {
@@ -86,7 +86,7 @@ func TestEndToEnd(t *testing.T) {
{"Echo", nil, mkV(), nil},
{"Echo", mkV("msg", "hola"), mkV("msg", "hola"), nil},
{"Hola", mkV("name", "marola"), mkV("greeting", "Hola marola"), nil},
{"HolaErr", nil, nil, testErr},
{"HolaErr", nil, nil, errTest},
{"UnknownMethod", nil, nil, errUnknownMethod},
}

View File

@@ -5,6 +5,7 @@ import (
"bytes"
"context"
"crypto/tls"
"errors"
"flag"
"fmt"
"io"
@@ -944,7 +945,7 @@ func (c *Conn) runPostDataHook(data []byte) ([]byte, bool, error) {
// The error contains the last line of stdout, so filters can pass
// some rejection information back to the sender.
err = fmt.Errorf(lastLine(string(out)))
err = errors.New(lastLine(string(out)))
return nil, permanent, err
}

View File

@@ -282,7 +282,6 @@ func (s *Server) periodicallyReload() {
return
}
//lint:ignore SA1015 This lasts the program's lifetime.
for range time.Tick(*reloadEvery) {
s.Reload()
}

View File

@@ -56,11 +56,11 @@ func main() {
}
conn, err = tls.Dial("tcp", *addr, tlsConfig)
defer conn.Close()
} else {
conn, err = net.Dial("tcp", *addr)
}
notnil(err)
defer conn.Close()
// Send the message.
client, err := smtp.NewClient(conn, *addr)