From d7dd6ef8451057db8ebc0fa504647a494ec0f8df Mon Sep 17 00:00:00 2001 From: "fox.cpp" Date: Fri, 24 Jan 2025 23:44:50 +0300 Subject: [PATCH] Fix more linter warnings --- framework/cfgparser/parse.go | 15 +++++++------- framework/config/module/check_action.go | 21 +++++++++++--------- internal/auth/auth_test.go | 1 - internal/check/milter/milter_test.go | 2 +- internal/smtpconn/smtpconn.go | 1 - internal/target/remote/remote_test.go | 2 -- internal/target/smtp/smtp_downstream_test.go | 2 -- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/framework/cfgparser/parse.go b/framework/cfgparser/parse.go index 5eabc3c0..aed01e3d 100644 --- a/framework/cfgparser/parse.go +++ b/framework/cfgparser/parse.go @@ -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 @@ -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). diff --git a/framework/config/module/check_action.go b/framework/config/module/check_action.go index 5061674a..cac3278c 100644 --- a/framework/config/module/check_action.go +++ b/framework/config/module/check_action.go @@ -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 diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go index 61fcd364..65ffee4e 100644 --- a/internal/auth/auth_test.go +++ b/internal/auth/auth_test.go @@ -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 { diff --git a/internal/check/milter/milter_test.go b/internal/check/milter/milter_test.go index d2ec19d3..97978517 100644 --- a/internal/check/milter/milter_test.go +++ b/internal/check/milter/milter_test.go @@ -58,4 +58,4 @@ func TestRejectInvalidEndpoints(t *testing.T) { return } } -} \ No newline at end of file +} diff --git a/internal/smtpconn/smtpconn.go b/internal/smtpconn/smtpconn.go index 0c73ed76..7f66bd23 100644 --- a/internal/smtpconn/smtpconn.go +++ b/internal/smtpconn/smtpconn.go @@ -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 { diff --git a/internal/target/remote/remote_test.go b/internal/target/remote/remote_test.go index ae561582..4998e0c6 100644 --- a/internal/target/remote/remote_test.go +++ b/internal/target/remote/remote_test.go @@ -27,7 +27,6 @@ import ( "os" "strconv" "testing" - "time" "github.com/emersion/go-message/textproto" "github.com/emersion/go-smtp" @@ -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) } diff --git a/internal/target/smtp/smtp_downstream_test.go b/internal/target/smtp/smtp_downstream_test.go index 93827e27..011ca04a 100644 --- a/internal/target/smtp/smtp_downstream_test.go +++ b/internal/target/smtp/smtp_downstream_test.go @@ -25,7 +25,6 @@ import ( "os" "strconv" "testing" - "time" "github.com/emersion/go-smtp" "github.com/foxcpp/maddy/framework/config" @@ -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) }