From cf92969719b5b30925340e5b837772a0757464f6 Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Thu, 8 May 2025 21:23:42 -0700 Subject: [PATCH] chore: Update golangci lint to 2.0.x (#572) * Update to golangci lint 2.0.x Signed-off-by: James Hillyerd * Fix new lint warnings Signed-off-by: James Hillyerd --------- Signed-off-by: James Hillyerd --- .github/workflows/lint.yml | 2 +- .golangci.yml | 52 ++++++++++++++++++++------------------ pkg/server/pop3/handler.go | 4 +-- pkg/server/smtp/handler.go | 6 ++--- pkg/test/manager.go | 2 +- pkg/test/storage_suite.go | 2 +- 6 files changed, 36 insertions(+), 32 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8ca474f..5e64bd0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,6 +12,6 @@ jobs: with: go-version: '1.24' - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 with: version: latest diff --git a/.golangci.yml b/.golangci.yml index 18a5190..6fab6e7 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,4 @@ -run: - timeout: 5m +version: "2" linters: enable: - asasalint @@ -10,29 +9,17 @@ linters: - contextcheck - copyloopvar - decorder - # - dupl - # - dupword - durationcheck - errchkjson - errname - # - errorlint - # - exhaustive - # - forcetypeassert - ginkgolinter - gocheckcompilerdirectives - # - gochecknoinits - gochecksumtype - gocritic - # - godot - # - goerr113 - - gofmt - # - gofumpt - goheader - - goimports - gomoddirectives - gomodguard - goprintffuncname - # - gosec - gosmopolitan - grouper - importas @@ -44,8 +31,6 @@ linters: - misspell - musttag - nilerr - # - nilnil - # - nlreturn - noctx - nolintlint - nosprintfhostport @@ -55,24 +40,43 @@ linters: - promlinter - protogetter - reassign - # - revive - rowserrcheck - sloglint - - stylecheck + - staticcheck - tagliatelle - testableexamples - testifylint - thelper - tparallel - # - unconvert - unparam - usestdlibvars - usetesting - wastedassign - whitespace - zerologlint -linters-settings: - tagliatelle: - case: - rules: - json: kebab + settings: + tagliatelle: + case: + rules: + json: kebab + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/pkg/server/pop3/handler.go b/pkg/server/pop3/handler.go index 7181a4a..8e8364d 100644 --- a/pkg/server/pop3/handler.go +++ b/pkg/server/pop3/handler.go @@ -214,7 +214,7 @@ func (s *Session) authorizationHandler(cmd string, args []string) { s.enterState(QUIT) case "STLS": - if !s.Server.config.TLSEnabled || s.Server.config.ForceTLS { + if !s.config.TLSEnabled || s.config.ForceTLS { // Invalid command since TLS unconfigured. s.logger.Debug().Msgf("-ERR TLS unavailable on the server") s.send("-ERR TLS unavailable on the server") @@ -230,7 +230,7 @@ func (s *Session) authorizationHandler(cmd string, args []string) { // Start TLS connection handshake. s.send("+OK Begin TLS Negotiation") - tlsConn := tls.Server(s.conn, s.Server.tlsConfig) + tlsConn := tls.Server(s.conn, s.tlsConfig) if err := tlsConn.Handshake(); err != nil { s.logger.Error().Msgf("-ERR TLS handshake failed %v", err) s.ooSeq(cmd) diff --git a/pkg/server/smtp/handler.go b/pkg/server/smtp/handler.go index b353f11..d0f6779 100644 --- a/pkg/server/smtp/handler.go +++ b/pkg/server/smtp/handler.go @@ -300,7 +300,7 @@ func (s *Session) greetHandler(cmd string, arg string) { s.send("250-" + readyBanner) s.send("250-8BITMIME") s.send("250-AUTH PLAIN LOGIN") - if s.Server.config.TLSEnabled && !s.Server.config.ForceTLS && s.Server.tlsConfig != nil && s.tlsState == nil { + if s.config.TLSEnabled && !s.config.ForceTLS && s.tlsConfig != nil && s.tlsState == nil { s.send("250-STARTTLS") } s.send(fmt.Sprintf("250 SIZE %v", s.config.MaxMessageBytes)) @@ -338,7 +338,7 @@ func (s *Session) passwordHandler() { func (s *Session) readyHandler(cmd string, arg string) { switch cmd { case "STARTTLS": - if !s.Server.config.TLSEnabled { + if !s.config.TLSEnabled { // Invalid command since TLS unconfigured. s.logger.Debug().Msgf("454 TLS unavailable on the server") s.send("454 TLS unavailable on the server") @@ -354,7 +354,7 @@ func (s *Session) readyHandler(cmd string, arg string) { // Start TLS connection handshake. s.send("220 STARTTLS") - tlsConn := tls.Server(s.conn, s.Server.tlsConfig) + tlsConn := tls.Server(s.conn, s.tlsConfig) s.conn = tlsConn s.text = textproto.NewConn(s.conn) s.tlsState = new(tls.ConnectionState) diff --git a/pkg/test/manager.go b/pkg/test/manager.go index 5a4e2ba..4614b92 100644 --- a/pkg/test/manager.go +++ b/pkg/test/manager.go @@ -70,7 +70,7 @@ func (m *ManagerStub) MarkSeen(mailbox, id string) error { } for _, msg := range m.mailboxes[mailbox] { if msg.ID == id { - msg.MessageMetadata.Seen = true + msg.Seen = true return nil } } diff --git a/pkg/test/storage_suite.go b/pkg/test/storage_suite.go index 31231d8..00c3ad7 100644 --- a/pkg/test/storage_suite.go +++ b/pkg/test/storage_suite.go @@ -379,7 +379,7 @@ func testPurge(s storeSuite) { } gotEvents = append(gotEvents, ev) } - assert.Equal(s, len(subjects), len(gotEvents), + assert.Len(s, gotEvents, len(subjects), "expected delete event for each message in mailbox") }