diff --git a/.golangci.yml b/.golangci.yml index 72d651cd..55c72a90 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -88,6 +88,7 @@ linters: - durationcheck # check for two durations multiplied together [fast: false, auto-fix: false] - exhaustive # check exhaustiveness of enum switch statements [fast: false, auto-fix: false] - exportloopref # checks for pointers to enclosing loop variables [fast: false, auto-fix: false] + - copyloopvar # detects places where loop variables are copied. - forcetypeassert # finds forced type assertions [fast: true, auto-fix: false] - godot # Check if comments end in a period [fast: true, auto-fix: true] - goheader # Checks is file header matches to pattern [fast: true, auto-fix: false] diff --git a/Makefile b/Makefile index 6464ce94..e933b618 100644 --- a/Makefile +++ b/Makefile @@ -189,7 +189,7 @@ ${RESOURCE_FILE}: ./dist/info.rc ./dist/${SRC_ICO} .FORCE ## Dev dependencies .PHONY: install-devel-tools install-linter install-go-mod-outdated install-git-hooks -LINTVER:="v1.59.1" +LINTVER:="v1.61.0" LINTSRC:="https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" install-dev-dependencies: install-devel-tools install-linter install-go-mod-outdated diff --git a/internal/bridge/bridge.go b/internal/bridge/bridge.go index 3d6dca97..63387292 100644 --- a/internal/bridge/bridge.go +++ b/internal/bridge/bridge.go @@ -636,7 +636,7 @@ func loadTLSConfig(vault *vault.Vault) (*tls.Config, error) { }, nil } -func min(a, b time.Duration) time.Duration { +func min(a, b time.Duration) time.Duration { //nolint:predeclared if a < b { return a } diff --git a/internal/configstatus/config_status.go b/internal/configstatus/config_status.go index e4b9067a..a8ec2e71 100644 --- a/internal/configstatus/config_status.go +++ b/internal/configstatus/config_status.go @@ -96,7 +96,7 @@ func (status *ConfigurationStatus) IsPending() bool { } func (status *ConfigurationStatus) isPendingSinceMin() int { - if min := int(time.Since(status.Data.DataV1.PendingSince).Minutes()); min > 0 { + if min := int(time.Since(status.Data.DataV1.PendingSince).Minutes()); min > 0 { //nolint:predeclared return min } return 0 @@ -211,7 +211,7 @@ func (data *ConfigurationStatusData) clickedLinkToString() string { var str = "" var first = true for i := 0; i < 64; i++ { - if data.hasLinkClicked(uint64(i)) { + if data.hasLinkClicked(uint64(i)) { //nolint:gosec // disable G115 if !first { str += "," } else { diff --git a/internal/frontend/grpc/event_factory.go b/internal/frontend/grpc/event_factory.go index a1561b99..8be0d9b4 100644 --- a/internal/frontend/grpc/event_factory.go +++ b/internal/frontend/grpc/event_factory.go @@ -214,7 +214,10 @@ func NewUserBadEvent(userID string, errorMessage string) *StreamEvent { } func NewUsedBytesChangedEvent(userID string, usedBytes uint64) *StreamEvent { - return userEvent(&UserEvent{Event: &UserEvent_UsedBytesChangedEvent{UsedBytesChangedEvent: &UsedBytesChangedEvent{UserID: userID, UsedBytes: int64(usedBytes)}}}) + return userEvent(&UserEvent{Event: &UserEvent_UsedBytesChangedEvent{UsedBytesChangedEvent: &UsedBytesChangedEvent{ + UserID: userID, + UsedBytes: int64(usedBytes), //nolint:gosec // disable G115 + }}}) } func newIMAPLoginFailedEvent(username string) *StreamEvent { diff --git a/internal/frontend/grpc/service_methods.go b/internal/frontend/grpc/service_methods.go index 778bbc13..d59c675e 100644 --- a/internal/frontend/grpc/service_methods.go +++ b/internal/frontend/grpc/service_methods.go @@ -717,8 +717,8 @@ func (s *Service) MailServerSettings(_ context.Context, _ *emptypb.Empty) (*Imap state: protoimpl.MessageState{}, sizeCache: 0, unknownFields: nil, - ImapPort: int32(s.bridge.GetIMAPPort()), - SmtpPort: int32(s.bridge.GetSMTPPort()), + ImapPort: int32(s.bridge.GetIMAPPort()), //nolint:gosec // disable G115 + SmtpPort: int32(s.bridge.GetSMTPPort()), //nolint:gosec // disable G115 UseSSLForImap: s.bridge.GetIMAPSSL(), UseSSLForSmtp: s.bridge.GetSMTPSSL(), }, nil @@ -864,8 +864,8 @@ func base64Decode(in []byte) ([]byte, error) { func (s *Service) getMailServerSettings() *ImapSmtpSettings { return &ImapSmtpSettings{ - ImapPort: int32(s.bridge.GetIMAPPort()), - SmtpPort: int32(s.bridge.GetSMTPPort()), + ImapPort: int32(s.bridge.GetIMAPPort()), //nolint:gosec // disable G115 + SmtpPort: int32(s.bridge.GetSMTPPort()), //nolint:gosec // disable G115 UseSSLForImap: s.bridge.GetIMAPSSL(), UseSSLForSmtp: s.bridge.GetSMTPSSL(), } diff --git a/internal/frontend/grpc/utils.go b/internal/frontend/grpc/utils.go index fec63759..afed8484 100644 --- a/internal/frontend/grpc/utils.go +++ b/internal/frontend/grpc/utils.go @@ -71,8 +71,8 @@ func grpcUserFromInfo(user bridge.UserInfo) *User { AvatarText: getInitials(user.Username), State: userStateToGrpc(user.State), SplitMode: user.AddressMode == vault.SplitMode, - UsedBytes: int64(user.UsedSpace), - TotalBytes: int64(user.MaxSpace), + UsedBytes: int64(user.UsedSpace), //nolint:gosec // disable G115 + TotalBytes: int64(user.MaxSpace), //nolint:gosec // disable G115 Password: user.BridgePass, Addresses: user.Addresses, } diff --git a/internal/kb/suggester.go b/internal/kb/suggester.go index 512309ee..966c840e 100644 --- a/internal/kb/suggester.go +++ b/internal/kb/suggester.go @@ -99,7 +99,7 @@ func GetArticleIndex(url string) (uint64, error) { if index == -1 { return 0, ErrArticleNotFound } - return uint64(index), nil + return uint64(index), nil //nolint:gosec // disable G115 } func simplifyUserInput(input string) string { diff --git a/internal/network/proton.go b/internal/network/proton.go index 3775b7c1..29aae338 100644 --- a/internal/network/proton.go +++ b/internal/network/proton.go @@ -31,7 +31,7 @@ type CoolDownProvider interface { Reset() } -func jitter(max int) time.Duration { +func jitter(max int) time.Duration { //nolint:predeclared return time.Duration(rand.Intn(max)) * time.Second //nolint:gosec } diff --git a/internal/services/imapsmtpserver/imap.go b/internal/services/imapsmtpserver/imap.go index 5783231b..806b6c56 100644 --- a/internal/services/imapsmtpserver/imap.go +++ b/internal/services/imapsmtpserver/imap.go @@ -156,9 +156,9 @@ func newIMAPServer( func getGluonVersionInfo(version *semver.Version) gluon.Option { return gluon.WithVersionInfo( - int(version.Major()), - int(version.Minor()), - int(version.Patch()), + int(version.Major()), //nolint:gosec // disable G115 + int(version.Minor()), //nolint:gosec // disable G115 + int(version.Patch()), //nolint:gosec // disable G115 constants.FullAppName, "TODO", "TODO", diff --git a/internal/services/syncservice/stage_build.go b/internal/services/syncservice/stage_build.go index e1d8208a..e9bb14a3 100644 --- a/internal/services/syncservice/stage_build.go +++ b/internal/services/syncservice/stage_build.go @@ -114,7 +114,7 @@ func (b *BuildStage) run(ctx context.Context) { messages: nil, }); err != nil { err = fmt.Errorf("failed to produce output for next stage: %w", err) - logrus.Errorf(err.Error()) + logrus.Error(err.Error()) req.job.onError(err) } @@ -217,7 +217,7 @@ func chunkSyncBuilderBatch(batch []proton.FullMessage, maxMemory uint64) [][]pro for _, v := range batch { var dataSize uint64 for _, a := range v.Attachments { - dataSize += uint64(a.Size) + dataSize += uint64(a.Size) //nolint:gosec // disable G115 } // 2x increase for attachment due to extra memory needed for decrypting and writing diff --git a/internal/services/syncservice/stage_download.go b/internal/services/syncservice/stage_download.go index e8914e1b..17144cd0 100644 --- a/internal/services/syncservice/stage_download.go +++ b/internal/services/syncservice/stage_download.go @@ -231,7 +231,7 @@ func downloadAttachment(ctx context.Context, cache *DownloadCache, client APICli } type DownloadRateModifier interface { - Apply(wasSuccess bool, current int, max int) int + Apply(wasSuccess bool, current int, max int) int //nolint:predeclared } func autoDownloadRate[T any, R any]( @@ -285,7 +285,7 @@ func autoDownloadRate[T any, R any]( type DefaultDownloadRateModifier struct{} -func (d DefaultDownloadRateModifier) Apply(wasSuccess bool, current int, max int) int { +func (d DefaultDownloadRateModifier) Apply(wasSuccess bool, current int, max int) int { //nolint:predeclared if !wasSuccess { return 2 } diff --git a/internal/services/syncservice/stage_metadata.go b/internal/services/syncservice/stage_metadata.go index 1cd6a205..adf12538 100644 --- a/internal/services/syncservice/stage_metadata.go +++ b/internal/services/syncservice/stage_metadata.go @@ -217,7 +217,7 @@ func (m *metadataIterator) Next(maxDownloadMem uint64, metadataPageSize int, max } for idx, meta := range m.remaining { - nextSize := m.expectedSize + uint64(meta.Size) + nextSize := m.expectedSize + uint64(meta.Size) //nolint:gosec // disable G115 if nextSize >= maxDownloadMem || len(m.downloadReqIDs) >= maxMessages { m.expectedSize = 0 m.remaining = m.remaining[idx:] diff --git a/internal/services/useridentity/service.go b/internal/services/useridentity/service.go index e81a6c94..7e916da8 100644 --- a/internal/services/useridentity/service.go +++ b/internal/services/useridentity/service.go @@ -105,10 +105,10 @@ func (s *Service) CheckAuth(ctx context.Context, email string, password []byte) func (s *Service) HandleUsedSpaceEvent(ctx context.Context, newSpace int64) error { s.log.Info("Handling User Space Changed event") - if s.identity.OnUserSpaceChanged(uint64(newSpace)) { + if s.identity.OnUserSpaceChanged(uint64(newSpace)) { //nolint:gosec // disable G115 s.eventPublisher.PublishEvent(ctx, events.UsedSpaceChanged{ UserID: s.identity.User.ID, - UsedSpace: uint64(newSpace), + UsedSpace: uint64(newSpace), //nolint:gosec // disable G115 }) } diff --git a/tests/imap_test.go b/tests/imap_test.go index 57684e64..8245e6f7 100644 --- a/tests/imap_test.go +++ b/tests/imap_test.go @@ -21,6 +21,7 @@ import ( "bytes" "encoding/base64" "encoding/json" + "errors" "fmt" "io" "os" @@ -658,7 +659,7 @@ func (s *scenario) imapClientsMoveMessageWithSubjectUserFromToByOrderedOperation case "EXPUNGE": expungeErr = sourceClient.Expunge(nil) default: - return fmt.Errorf("unknown IMAP operation " + op) + return errors.New("unknown IMAP operation " + op) } time.Sleep(100 * time.Millisecond) }