mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 08:23:48 +03:00
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:
parent
8bc554b671
commit
b7a0904907
8 changed files with 7 additions and 111 deletions
|
@ -21,12 +21,9 @@ import (
|
|||
|
||||
"github.com/mjl-/mox/dmarcrpt"
|
||||
"github.com/mjl-/mox/dns"
|
||||
"github.com/mjl-/mox/mlog"
|
||||
"github.com/mjl-/mox/mox-"
|
||||
)
|
||||
|
||||
var xlog = mlog.New("dmarcdb")
|
||||
|
||||
var (
|
||||
DBTypes = []any{DomainFeedback{}} // Types stored in DB.
|
||||
DB *bstore.DB // Exported for backups.
|
||||
|
|
|
@ -310,10 +310,8 @@ func (m *Message) Compose(log *mlog.Log, smtputf8 bool) ([]byte, error) {
|
|||
headers = m.Original
|
||||
} else if err != nil {
|
||||
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{}
|
||||
if smtputf8 {
|
||||
|
|
|
@ -1072,16 +1072,6 @@ func (c *Conn) xnamespaceDescr() NamespaceDescr {
|
|||
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.
|
||||
func (c *Conn) xneedDisabled(msg string, caps ...Capability) {
|
||||
for _, cap := range caps {
|
||||
|
|
|
@ -146,23 +146,6 @@ func (p *parser) xtake1n(n int, what string) string {
|
|||
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 {
|
||||
p.xnonempty()
|
||||
for i, c := range p.orig[p.o:] {
|
||||
|
@ -182,13 +165,6 @@ func (p *parser) xtaken(n int) string {
|
|||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
// ../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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
// 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.
|
||||
func disabledTestReference(t *testing.T) {
|
||||
func DisabledTestReference(t *testing.T) {
|
||||
tc := start(t)
|
||||
defer tc.close()
|
||||
tc.client.Login("mjl@mox.example", "testtest")
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
|
@ -21,8 +20,6 @@ import (
|
|||
"github.com/mjl-/mox/smtpclient"
|
||||
)
|
||||
|
||||
var ctxbg = context.Background()
|
||||
|
||||
func tcheck(t *testing.T, err error, errmsg string) {
|
||||
if err != nil {
|
||||
t.Helper()
|
||||
|
|
|
@ -29,8 +29,8 @@ import (
|
|||
var (
|
||||
xlog = mlog.New("junk")
|
||||
|
||||
errBadContentType = errors.New("bad content-type") // sure sign of spam
|
||||
errClosed = errors.New("filter is closed")
|
||||
// errBadContentType = errors.New("bad content-type") // sure sign of spam, todo: use this error
|
||||
errClosed = errors.New("filter is closed")
|
||||
)
|
||||
|
||||
type word struct {
|
||||
|
|
|
@ -1340,13 +1340,10 @@ func (c *conn) cmdRcpt(p *parser) {
|
|||
for p.space() {
|
||||
// ../rfc/5321:2275
|
||||
key := p.xparamKeyword()
|
||||
K := strings.ToUpper(key)
|
||||
switch K {
|
||||
// K := strings.ToUpper(key)
|
||||
// todo future: DSN, ../rfc/3461, with "NOTIFY"
|
||||
default:
|
||||
// ../rfc/5321:2230
|
||||
xsmtpUserErrorf(smtp.C555UnrecognizedAddrParams, smtp.SeSys3NotSupported3, "unrecognized parameter %q", key)
|
||||
}
|
||||
// ../rfc/5321:2230
|
||||
xsmtpUserErrorf(smtp.C555UnrecognizedAddrParams, smtp.SeSys3NotSupported3, "unrecognized parameter %q", key)
|
||||
}
|
||||
p.xend()
|
||||
|
||||
|
|
Loading…
Reference in a new issue