cleanup for warnings by staticcheck

the warnings that remained were either unused code that i wanted to use in the
future, or other type's of todo's. i've been mentally ignoring them, assuming i
would get back to them soon enough to fix them. but that hasn't happened yet,
and it's better to have a clean list with only actual isses.
This commit is contained in:
Mechiel Lukkien 2023-07-24 13:55:36 +02:00
parent 8bc554b671
commit b7a0904907
No known key found for this signature in database
8 changed files with 7 additions and 111 deletions

View file

@ -21,12 +21,9 @@ import (
"github.com/mjl-/mox/dmarcrpt" "github.com/mjl-/mox/dmarcrpt"
"github.com/mjl-/mox/dns" "github.com/mjl-/mox/dns"
"github.com/mjl-/mox/mlog"
"github.com/mjl-/mox/mox-" "github.com/mjl-/mox/mox-"
) )
var xlog = mlog.New("dmarcdb")
var ( var (
DBTypes = []any{DomainFeedback{}} // Types stored in DB. DBTypes = []any{DomainFeedback{}} // Types stored in DB.
DB *bstore.DB // Exported for backups. DB *bstore.DB // Exported for backups.

View file

@ -310,10 +310,8 @@ func (m *Message) Compose(log *mlog.Log, smtputf8 bool) ([]byte, error) {
headers = m.Original headers = m.Original
} else if err != nil { } else if err != nil {
return nil, err return nil, err
} else {
// This is a whole message. We still only include the headers.
// todo: include the whole body.
} }
// Else, this is a whole message. We still only include the headers. todo: include the whole body.
origHdr := textproto.MIMEHeader{} origHdr := textproto.MIMEHeader{}
if smtputf8 { if smtputf8 {

View file

@ -1072,16 +1072,6 @@ func (c *Conn) xnamespaceDescr() NamespaceDescr {
return NamespaceDescr{prefix, b, exts} return NamespaceDescr{prefix, b, exts}
} }
// require one of caps to be enabled.
func (c *Conn) xneedEnabled(msg string, caps ...Capability) {
for _, cap := range caps {
if _, ok := c.CapEnabled[cap]; ok {
return
}
}
c.xerrorf("%s: need one of following enabled capabilities: %v", msg, caps)
}
// require all of caps to be disabled. // require all of caps to be disabled.
func (c *Conn) xneedDisabled(msg string, caps ...Capability) { func (c *Conn) xneedDisabled(msg string, caps ...Capability) {
for _, cap := range caps { for _, cap := range caps {

View file

@ -146,23 +146,6 @@ func (p *parser) xtake1n(n int, what string) string {
return p.xtaken(n) return p.xtaken(n)
} }
func (p *parser) xtake1fn(fn func(i int, c rune) bool) string {
i := 0
s := ""
for _, c := range p.upper[p.o:] {
if !fn(i, c) {
break
}
s += string(c)
i++
}
if s == "" {
p.xerrorf("expected at least one character")
}
p.o += len(s)
return s
}
func (p *parser) xtakechars(s string, what string) string { func (p *parser) xtakechars(s string, what string) string {
p.xnonempty() p.xnonempty()
for i, c := range p.orig[p.o:] { for i, c := range p.orig[p.o:] {
@ -182,13 +165,6 @@ func (p *parser) xtaken(n int) string {
return r return r
} }
func (p *parser) peekn(n int) (string, bool) {
if len(p.upper[p.o:]) < n {
return "", false
}
return p.upper[p.o : p.o+n], true
}
func (p *parser) space() bool { func (p *parser) space() bool {
return p.take(" ") return p.take(" ")
} }
@ -904,62 +880,3 @@ func (p *parser) xdate() time.Time {
} }
return time.Date(year, mon, day, 0, 0, 0, 0, time.UTC) return time.Date(year, mon, day, 0, 0, 0, 0, time.UTC)
} }
// ../rfc/9051:7090 ../rfc/4466:716
func (p *parser) xtaggedExtLabel() string {
return p.xtake1fn(func(i int, c rune) bool {
return c >= 'A' && c <= 'Z' || c == '-' || c == '_' || c == '.' || i > 0 && (c >= '0' && c <= '9' || c == ':')
})
}
// no return value since we don't currently use the value.
// ../rfc/9051:7111 ../rfc/4466:749
func (p *parser) xtaggedExtVal() {
if p.take("(") {
if p.take(")") {
return
}
p.xtaggedExtComp()
p.xtake(")")
} else {
p.xtaggedExtSimple()
}
}
// ../rfc/9051:7109 ../rfc/4466:747
func (p *parser) xtaggedExtSimple() {
s := p.digits()
if s == "" {
p.xnumSet()
}
// This can be a number64, or the start of a sequence-set. A sequence-set can also
// start with a number, but only an uint32. After the number we'll try to continue
// parsing as a sequence-set.
_, err := strconv.ParseInt(s, 10, 64)
if err != nil {
p.xerrorf("parsing int: %v", err)
}
if p.take(":") {
if !p.take("*") {
p.xnznumber()
}
}
for p.take(",") {
p.xnumRange()
}
}
// ../rfc/9051:7111 ../rfc/4466:735
func (p *parser) xtaggedExtComp() {
if p.take("(") {
p.xtaggedExtComp()
p.xtake(")")
return
}
p.xastring()
for p.space() {
p.xtaggedExtComp()
}
}

View file

@ -648,7 +648,7 @@ func TestSequence(t *testing.T) {
// Test that a message that is expunged by another session can be read as long as a // Test that a message that is expunged by another session can be read as long as a
// reference is held by a session. New sessions do not see the expunged message. // reference is held by a session. New sessions do not see the expunged message.
// todo: possibly implement the additional reference counting. so far it hasn't been worth the trouble. // todo: possibly implement the additional reference counting. so far it hasn't been worth the trouble.
func disabledTestReference(t *testing.T) { func DisabledTestReference(t *testing.T) {
tc := start(t) tc := start(t)
defer tc.close() defer tc.close()
tc.client.Login("mjl@mox.example", "testtest") tc.client.Login("mjl@mox.example", "testtest")

View file

@ -3,7 +3,6 @@
package main package main
import ( import (
"context"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"net" "net"
@ -21,8 +20,6 @@ import (
"github.com/mjl-/mox/smtpclient" "github.com/mjl-/mox/smtpclient"
) )
var ctxbg = context.Background()
func tcheck(t *testing.T, err error, errmsg string) { func tcheck(t *testing.T, err error, errmsg string) {
if err != nil { if err != nil {
t.Helper() t.Helper()

View file

@ -29,7 +29,7 @@ import (
var ( var (
xlog = mlog.New("junk") xlog = mlog.New("junk")
errBadContentType = errors.New("bad content-type") // sure sign of spam // errBadContentType = errors.New("bad content-type") // sure sign of spam, todo: use this error
errClosed = errors.New("filter is closed") errClosed = errors.New("filter is closed")
) )

View file

@ -1340,14 +1340,11 @@ func (c *conn) cmdRcpt(p *parser) {
for p.space() { for p.space() {
// ../rfc/5321:2275 // ../rfc/5321:2275
key := p.xparamKeyword() key := p.xparamKeyword()
K := strings.ToUpper(key) // K := strings.ToUpper(key)
switch K {
// todo future: DSN, ../rfc/3461, with "NOTIFY" // todo future: DSN, ../rfc/3461, with "NOTIFY"
default:
// ../rfc/5321:2230 // ../rfc/5321:2230
xsmtpUserErrorf(smtp.C555UnrecognizedAddrParams, smtp.SeSys3NotSupported3, "unrecognized parameter %q", key) xsmtpUserErrorf(smtp.C555UnrecognizedAddrParams, smtp.SeSys3NotSupported3, "unrecognized parameter %q", key)
} }
}
p.xend() p.xend()
// todo future: for submission, should we do explicit verification that domains are fully qualified? also for mail from. ../rfc/6409:420 // todo future: for submission, should we do explicit verification that domains are fully qualified? also for mail from. ../rfc/6409:420