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:
@@ -3,8 +3,6 @@ package dkim
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto"
|
"crypto"
|
||||||
"crypto/ed25519"
|
|
||||||
"crypto/x509"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -36,7 +34,6 @@ const exampleRSAKeyB64 = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQ" +
|
|||||||
"tdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB"
|
"tdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB"
|
||||||
|
|
||||||
var exampleRSAKeyBuf, _ = base64.StdEncoding.DecodeString(exampleRSAKeyB64)
|
var exampleRSAKeyBuf, _ = base64.StdEncoding.DecodeString(exampleRSAKeyB64)
|
||||||
var exampleRSAKey, _ = x509.ParsePKCS1PublicKey(exampleRSAKeyBuf)
|
|
||||||
|
|
||||||
// Ed25519 key from the RFC example.
|
// Ed25519 key from the RFC example.
|
||||||
// https://datatracker.ietf.org/doc/html/rfc8463#appendix-A.2
|
// https://datatracker.ietf.org/doc/html/rfc8463#appendix-A.2
|
||||||
@@ -44,7 +41,6 @@ const exampleEd25519KeyB64 = "11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo="
|
|||||||
|
|
||||||
var exampleEd25519KeyBuf, _ = base64.StdEncoding.DecodeString(
|
var exampleEd25519KeyBuf, _ = base64.StdEncoding.DecodeString(
|
||||||
exampleEd25519KeyB64)
|
exampleEd25519KeyB64)
|
||||||
var exampleEd25519Key = ed25519.PublicKey(exampleEd25519KeyBuf)
|
|
||||||
|
|
||||||
var results = map[string][]string{}
|
var results = map[string][]string{}
|
||||||
var resultErr = map[string]error{}
|
var resultErr = map[string]error{}
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ func Hola(tr *trace.Trace, input url.Values) (url.Values, error) {
|
|||||||
return output, nil
|
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) {
|
func HolaErr(tr *trace.Trace, input url.Values) (url.Values, error) {
|
||||||
return nil, testErr
|
return nil, errTest
|
||||||
}
|
}
|
||||||
|
|
||||||
type testServer struct {
|
type testServer struct {
|
||||||
@@ -86,7 +86,7 @@ func TestEndToEnd(t *testing.T) {
|
|||||||
{"Echo", nil, mkV(), nil},
|
{"Echo", nil, mkV(), nil},
|
||||||
{"Echo", mkV("msg", "hola"), mkV("msg", "hola"), nil},
|
{"Echo", mkV("msg", "hola"), mkV("msg", "hola"), nil},
|
||||||
{"Hola", mkV("name", "marola"), mkV("greeting", "Hola marola"), nil},
|
{"Hola", mkV("name", "marola"), mkV("greeting", "Hola marola"), nil},
|
||||||
{"HolaErr", nil, nil, testErr},
|
{"HolaErr", nil, nil, errTest},
|
||||||
{"UnknownMethod", nil, nil, errUnknownMethod},
|
{"UnknownMethod", nil, nil, errUnknownMethod},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"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
|
// The error contains the last line of stdout, so filters can pass
|
||||||
// some rejection information back to the sender.
|
// some rejection information back to the sender.
|
||||||
err = fmt.Errorf(lastLine(string(out)))
|
err = errors.New(lastLine(string(out)))
|
||||||
return nil, permanent, err
|
return nil, permanent, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -282,7 +282,6 @@ func (s *Server) periodicallyReload() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//lint:ignore SA1015 This lasts the program's lifetime.
|
|
||||||
for range time.Tick(*reloadEvery) {
|
for range time.Tick(*reloadEvery) {
|
||||||
s.Reload()
|
s.Reload()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn, err = tls.Dial("tcp", *addr, tlsConfig)
|
conn, err = tls.Dial("tcp", *addr, tlsConfig)
|
||||||
defer conn.Close()
|
|
||||||
} else {
|
} else {
|
||||||
conn, err = net.Dial("tcp", *addr)
|
conn, err = net.Dial("tcp", *addr)
|
||||||
}
|
}
|
||||||
notnil(err)
|
notnil(err)
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
// Send the message.
|
// Send the message.
|
||||||
client, err := smtp.NewClient(conn, *addr)
|
client, err := smtp.NewClient(conn, *addr)
|
||||||
|
|||||||
Reference in New Issue
Block a user