1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 09:37:02 +00:00

chore: fix more capitalization style warnings (#487)

Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
James Hillyerd
2024-02-15 18:31:43 -08:00
committed by GitHub
parent baa2dbd3a1
commit ea585c4851
12 changed files with 60 additions and 60 deletions

View File

@@ -173,7 +173,7 @@ func openLog(level string, logfile string, json bool) (close func(), err error)
case "error":
zerolog.SetGlobalLevel(zerolog.ErrorLevel)
default:
return nil, fmt.Errorf("Log level %q not one of: debug, info, warn, error", level)
return nil, fmt.Errorf("log level %q not one of: debug, info, warn, error", level)
}
close = func() {}
var w io.Writer

View File

@@ -47,13 +47,13 @@ func TestAsyncBrokerEmitCallsMultipleListeners(t *testing.T) {
want := "hi"
broker.Emit(&want)
first_got, err := first()
firstGot, err := first()
require.NoError(t, err)
assert.Equal(t, want, *first_got)
assert.Equal(t, want, *firstGot)
second_got, err := second()
secondGot, err := second()
require.NoError(t, err)
assert.Equal(t, want, *second_got)
assert.Equal(t, want, *secondGot)
}
func TestAsyncBrokerAddingDuplicateNameReplacesPrevious(t *testing.T) {
@@ -66,13 +66,13 @@ func TestAsyncBrokerAddingDuplicateNameReplacesPrevious(t *testing.T) {
want := "hi"
broker.Emit(&want)
first_got, err := first()
firstGot, err := first()
require.Error(t, err)
assert.Nil(t, first_got)
assert.Nil(t, firstGot)
second_got, err := second()
secondGot, err := second()
require.NoError(t, err)
assert.Equal(t, want, *second_got)
assert.Equal(t, want, *secondGot)
}
func TestAsyncBrokerRemovingListenerSuccessful(t *testing.T) {
@@ -86,13 +86,13 @@ func TestAsyncBrokerRemovingListenerSuccessful(t *testing.T) {
want := "hi"
broker.Emit(&want)
first_got, err := first()
firstGot, err := first()
require.Error(t, err)
assert.Nil(t, first_got)
assert.Nil(t, firstGot)
second_got, err := second()
secondGot, err := second()
require.NoError(t, err)
assert.Equal(t, want, *second_got)
assert.Equal(t, want, *secondGot)
}
func TestAsyncBrokerRemovingMissingListener(t *testing.T) {

View File

@@ -28,13 +28,13 @@ func TestBrokerEmitCallsMultipleListeners(t *testing.T) {
broker := &extension.EventBroker[string, bool]{}
// Setup listeners.
var first_got, second_got string
var firstGot, secondGot string
first := func(s string) *bool {
first_got = s
firstGot = s
return nil
}
second := func(s string) *bool {
second_got = s
secondGot = s
return nil
}
@@ -43,11 +43,11 @@ func TestBrokerEmitCallsMultipleListeners(t *testing.T) {
want := "hi"
broker.Emit(&want)
if first_got != want {
t.Errorf("first got %q, want %q", first_got, want)
if firstGot != want {
t.Errorf("first got %q, want %q", firstGot, want)
}
if second_got != want {
t.Errorf("second got %q, want %q", second_got, want)
if secondGot != want {
t.Errorf("second got %q, want %q", secondGot, want)
}
}
@@ -77,13 +77,13 @@ func TestBrokerAddingDuplicateNameReplacesPrevious(t *testing.T) {
broker := &extension.EventBroker[string, bool]{}
// Setup listeners.
var first_got, second_got string
var firstGot, secondGot string
first := func(s string) *bool {
first_got = s
firstGot = s
return nil
}
second := func(s string) *bool {
second_got = s
secondGot = s
return nil
}
@@ -92,11 +92,11 @@ func TestBrokerAddingDuplicateNameReplacesPrevious(t *testing.T) {
want := "hi"
broker.Emit(&want)
if first_got != "" {
t.Errorf("first got %q, want empty string", first_got)
if firstGot != "" {
t.Errorf("first got %q, want empty string", firstGot)
}
if second_got != want {
t.Errorf("second got %q, want %q", second_got, want)
if secondGot != want {
t.Errorf("second got %q, want %q", secondGot, want)
}
}
@@ -104,13 +104,13 @@ func TestBrokerRemovingListenerSuccessful(t *testing.T) {
broker := &extension.EventBroker[string, bool]{}
// Setup listeners.
var first_got, second_got string
var firstGot, secondGot string
first := func(s string) *bool {
first_got = s
firstGot = s
return nil
}
second := func(s string) *bool {
second_got = s
secondGot = s
return nil
}
@@ -120,11 +120,11 @@ func TestBrokerRemovingListenerSuccessful(t *testing.T) {
want := "hi"
broker.Emit(&want)
if first_got != "" {
t.Errorf("first got %q, want empty string", first_got)
if firstGot != "" {
t.Errorf("first got %q, want empty string", firstGot)
}
if second_got != want {
t.Errorf("second got %q, want %q", second_got, want)
if secondGot != want {
t.Errorf("second got %q, want %q", secondGot, want)
}
}

View File

@@ -55,7 +55,7 @@ func unwrapInboundMessage(lv lua.LValue) (*event.InboundMessage, error) {
}
}
return nil, fmt.Errorf("Expected InboundMessage, got %q", lv.Type().String())
return nil, fmt.Errorf("expected InboundMessage, got %q", lv.Type().String())
}
// Gets a field value from InboundMessage user object. This emulates a Lua table,

View File

@@ -37,7 +37,7 @@ func New(conf config.Lua, extHost *extension.Host) (*Host, error) {
logger.Info().Msg("Script file not found")
return nil, nil
} else if fi.IsDir() {
return nil, fmt.Errorf("Lua script %v is a directory", scriptPath)
return nil, fmt.Errorf("lua script %v is a directory", scriptPath)
}
logger.Info().Msg("Loading script")

View File

@@ -45,7 +45,7 @@ func (a *Addressing) ExtractMailbox(address string) (string, error) {
}
if !ValidateDomainPart(domain) {
return "", fmt.Errorf("Domain part %q in %q failed validation", domain, address)
return "", fmt.Errorf("domain part %q in %q failed validation", domain, address)
}
return local + "@" + domain, nil
@@ -136,7 +136,7 @@ func ParseEmailAddress(address string) (local string, domain string, err error)
return "", "", err
}
if !ValidateDomainPart(domain) {
return "", "", fmt.Errorf("Domain part validation failed")
return "", "", fmt.Errorf("domain part validation failed")
}
return local, domain, nil
}
@@ -229,7 +229,7 @@ func extractDomainMailbox(address string) (string, error) {
}
if !ValidateDomainPart(domain) {
return "", fmt.Errorf("Domain part %q in %q failed validation", domain, address)
return "", fmt.Errorf("domain part %q in %q failed validation", domain, address)
}
return domain, nil
@@ -254,7 +254,7 @@ func parseEmailAddress(address string) (local string, domain string, err error)
}
address = address[end+1:]
if address == "" {
return "", "", fmt.Errorf("Address empty after removing route specification")
return "", "", fmt.Errorf("address empty after removing route specification")
}
}
@@ -296,7 +296,7 @@ LOOP:
// A single period is OK.
if prev == '.' {
// Sequence of periods is not permitted.
return "", "", fmt.Errorf("Sequence of periods is not permitted")
return "", "", fmt.Errorf("sequence of periods is not permitted")
}
err = buf.WriteByte(c)
if err != nil {
@@ -318,7 +318,7 @@ LOOP:
if i == 0 {
inStringQuote = true
} else {
return "", "", fmt.Errorf("Quoted string can only begin at start of address")
return "", "", fmt.Errorf("quoted string can only begin at start of address")
}
}
case c == '@':
@@ -331,16 +331,16 @@ LOOP:
} else {
// End of local-part.
if i > 128 {
return "", "", fmt.Errorf("Local part must not exceed 128 characters")
return "", "", fmt.Errorf("local part must not exceed 128 characters")
}
if prev == '.' {
return "", "", fmt.Errorf("Local part cannot end with a period")
return "", "", fmt.Errorf("local part cannot end with a period")
}
domain = address[i+1:]
break LOOP
}
case c > 127:
return "", "", fmt.Errorf("Characters outside of US-ASCII range not permitted")
return "", "", fmt.Errorf("characters outside of US-ASCII range not permitted")
default:
if inCharQuote || inStringQuote {
err = buf.WriteByte(c)
@@ -349,16 +349,16 @@ LOOP:
}
inCharQuote = false
} else {
return "", "", fmt.Errorf("Character %q must be quoted", c)
return "", "", fmt.Errorf("character %q must be quoted", c)
}
}
prev = c
}
if inCharQuote {
return "", "", fmt.Errorf("Cannot end address with unterminated quoted-pair")
return "", "", fmt.Errorf("cannot end address with unterminated quoted-pair")
}
if inStringQuote {
return "", "", fmt.Errorf("Cannot end address with unterminated string quote")
return "", "", fmt.Errorf("cannot end address with unterminated string quote")
}
return buf.String(), domain, nil
}
@@ -369,7 +369,7 @@ LOOP:
// quoted according to RFC3696.
func parseMailboxName(localPart string) (result string, err error) {
if localPart == "" {
return "", fmt.Errorf("Mailbox name cannot be empty")
return "", fmt.Errorf("mailbox name cannot be empty")
}
result = strings.ToLower(localPart)
invalid := make([]byte, 0, 10)
@@ -384,7 +384,7 @@ func parseMailboxName(localPart string) (result string, err error) {
}
}
if len(invalid) > 0 {
return "", fmt.Errorf("Mailbox name contained invalid character(s): %q", invalid)
return "", fmt.Errorf("mailbox name contained invalid character(s): %q", invalid)
}
if idx := strings.Index(result, "+"); idx > -1 {
result = result[0:idx]

View File

@@ -26,7 +26,7 @@ func MailboxListV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (
messages, err := ctx.Manager.GetMetadata(name)
if err != nil {
// This doesn't indicate empty, likely an IO error
return fmt.Errorf("Failed to get messages for %v: %v", name, err)
return fmt.Errorf("failed to get messages for %v: %v", name, err)
}
jmessages := make([]*model.JSONMessageHeaderV1, len(messages))
for i, msg := range messages {
@@ -108,7 +108,7 @@ func MailboxMarkSeenV1(w http.ResponseWriter, req *http.Request, ctx *web.Contex
dec := json.NewDecoder(req.Body)
dm := model.JSONMessageHeaderV1{}
if err := dec.Decode(&dm); err != nil {
return fmt.Errorf("Failed to decode JSON: %v", err)
return fmt.Errorf("failed to decode JSON: %v", err)
}
if dm.Seen {
err = ctx.Manager.MarkSeen(name, id)

View File

@@ -87,7 +87,7 @@ func (c *Client) GetMessageSource(name, id string) (*bytes.Buffer, error) {
}()
if resp.StatusCode != http.StatusOK {
return nil,
fmt.Errorf("Unexpected HTTP response status %v: %s", resp.StatusCode, resp.Status)
fmt.Errorf("unexpected HTTP response status %v: %s", resp.StatusCode, resp.Status)
}
buf := new(bytes.Buffer)
_, err = buf.ReadFrom(resp.Body)
@@ -103,7 +103,7 @@ func (c *Client) DeleteMessage(name, id string) error {
}
_ = resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Unexpected HTTP response status %v: %s", resp.StatusCode, resp.Status)
return fmt.Errorf("unexpected HTTP response status %v: %s", resp.StatusCode, resp.Status)
}
return nil
}
@@ -117,7 +117,7 @@ func (c *Client) PurgeMailbox(name string) error {
}
_ = resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Unexpected HTTP response status %v: %s", resp.StatusCode, resp.Status)
return fmt.Errorf("unexpected HTTP response status %v: %s", resp.StatusCode, resp.Status)
}
return nil
}

View File

@@ -34,7 +34,7 @@ func NewServer(pop3Config config.POP3, store storage.Store) (*Server, error) {
tlsConfig.Certificates[0], err = tls.LoadX509KeyPair(pop3Config.TLSCert, pop3Config.TLSPrivKey)
if err != nil {
slog.Error().Msgf("Failed loading X509 KeyPair: %v", err)
return nil, fmt.Errorf("Failed to configure TLS; %v", err)
return nil, fmt.Errorf("failed to configure TLS; %v", err)
// Do not silently turn off Security.
}
slog.Debug().Msg("TLS config available")

View File

@@ -307,7 +307,7 @@ func parseHelloArgument(arg string) (string, error) {
domain = arg[:idx]
}
if domain == "" {
return "", fmt.Errorf("Invalid domain")
return "", fmt.Errorf("invalid domain")
}
return domain, nil
}

View File

@@ -130,7 +130,7 @@ func (mb *mbox) readIndex() error {
dec := gob.NewDecoder(br)
name := ""
if err = dec.Decode(&name); err != nil {
return fmt.Errorf("Corrupt mailbox %q: %v", mb.indexPath, err)
return fmt.Errorf("corrupt mailbox %q: %v", mb.indexPath, err)
}
mb.name = name
for {
@@ -140,7 +140,7 @@ func (mb *mbox) readIndex() error {
if err == io.EOF {
break
}
return fmt.Errorf("Corrupt mailbox %q: %v", mb.indexPath, err)
return fmt.Errorf("corrupt mailbox %q: %v", mb.indexPath, err)
}
msg.mailbox = mb
mb.messages = append(mb.messages, msg)

View File

@@ -13,7 +13,7 @@ import (
func RootGreeting(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
greeting, err := os.ReadFile(ctx.RootConfig.Web.GreetingFile)
if err != nil {
return fmt.Errorf("Failed to load greeting: %v", err)
return fmt.Errorf("failed to load greeting: %v", err)
}
w.Header().Set("Content-Type", "text/html")