Skip to content

Commit

Permalink
Fix more linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
foxcpp committed Jan 24, 2025
1 parent dbc030c commit d7dd6ef
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
15 changes: 8 additions & 7 deletions framework/cfgparser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import (

// Node struct describes a parsed configurtion block or a simple directive.
//
// name arg0 arg1 {
// children0
// children1
// }
// name arg0 arg1 {
// children0
// children1
// }
type Node struct {
// Name is the first string at node's line.
Name string
Expand Down Expand Up @@ -209,9 +209,10 @@ func (ctx *parseContext) parseAsMacro(node *Node) (macroName string, args []stri
//
// The lexer's cursor should point to the opening brace
// name arg0 arg1 { #< this one
// c0
// c1
// }
//
// c0
// c1
// }
//
// To stay consistent with readNode after this function returns the lexer's cursor points
// to the last token of the black (closing brace).
Expand Down
21 changes: 12 additions & 9 deletions framework/config/module/check_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,22 @@ import (
// returns. It is intended to be used as follows:
//
// Add the configuration directive to allow user to specify the action:
// cfg.Custom("SOME_action", false, false,
// func() (interface{}, error) {
// return modconfig.FailAction{Quarantine: true}, nil
// }, modconfig.FailActionDirective, &yourModule.SOMEAction)
//
// cfg.Custom("SOME_action", false, false,
// func() (interface{}, error) {
// return modconfig.FailAction{Quarantine: true}, nil
// }, modconfig.FailActionDirective, &yourModule.SOMEAction)
//
// return in func literal is the default value, you might want to adjust it.
//
// Call yourModule.SOMEAction.Apply on CheckResult containing only the
// Reason field:
// func (yourModule YourModule) CheckConnection() module.CheckResult {
// return yourModule.SOMEAction.Apply(module.CheckResult{
// Reason: ...,
// })
// }
//
// func (yourModule YourModule) CheckConnection() module.CheckResult {
// return yourModule.SOMEAction.Apply(module.CheckResult{
// Reason: ...,
// })
// }
type FailAction struct {
Quarantine bool
Reject bool
Expand Down
1 change: 0 additions & 1 deletion internal/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func TestCheckDomainAuth(t *testing.T) {
}

for _, case_ := range cases {
case_ := case_
t.Run(fmt.Sprintf("%+v", case_), func(t *testing.T) {
loginName, allowed := CheckDomainAuth(case_.rawUsername, case_.perDomain, case_.allowedDomains)
if case_.loginName != "" && !allowed {
Expand Down
2 changes: 1 addition & 1 deletion internal/check/milter/milter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ func TestRejectInvalidEndpoints(t *testing.T) {
return
}
}
}
}
1 change: 0 additions & 1 deletion internal/smtpconn/smtpconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ func (c *C) Close() error {
c.Log.DebugMsg("QUIT error", "reason", c.wrapClientErr(err, c.serverName))
} else if errors.As(err, &netErr) &&
(netErr.Timeout() || netErr.Err.Error() == "write: broken pipe" || netErr.Err.Error() == "read: connection reset") {

// The case for silently closed connections.
c.Log.DebugMsg("QUIT error", "reason", c.wrapClientErr(err, c.serverName))
} else {
Expand Down
2 changes: 0 additions & 2 deletions internal/target/remote/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"os"
"strconv"
"testing"
"time"

"github.com/emersion/go-message/textproto"
"github.com/emersion/go-smtp"
Expand Down Expand Up @@ -1020,7 +1019,6 @@ func TestMain(m *testing.M) {
flag.Parse()

if *remoteSmtpPort == "random" {
rand.Seed(time.Now().UnixNano())
*remoteSmtpPort = strconv.Itoa(rand.Intn(65536-10000) + 10000)
}

Expand Down
2 changes: 0 additions & 2 deletions internal/target/smtp/smtp_downstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"os"
"strconv"
"testing"
"time"

"github.com/emersion/go-smtp"
"github.com/foxcpp/maddy/framework/config"
Expand Down Expand Up @@ -344,7 +343,6 @@ func TestMain(m *testing.M) {
flag.Parse()

if *remoteSmtpPort == "random" {
rand.Seed(time.Now().UnixNano())
*remoteSmtpPort = strconv.Itoa(rand.Intn(65536-10000) + 10000)
}

Expand Down

0 comments on commit d7dd6ef

Please sign in to comment.