chore: update golangci-lint to 1.61.0.

This commit is contained in:
Xavier Michelon
2024-10-09 12:40:22 +02:00
parent b481ce2203
commit bee2642aec
15 changed files with 29 additions and 24 deletions

View File

@ -88,6 +88,7 @@ linters:
- durationcheck # check for two durations multiplied together [fast: false, auto-fix: false] - durationcheck # check for two durations multiplied together [fast: false, auto-fix: false]
- exhaustive # check exhaustiveness of enum switch statements [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] - 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] - forcetypeassert # finds forced type assertions [fast: true, auto-fix: false]
- godot # Check if comments end in a period [fast: true, auto-fix: true] - 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] - goheader # Checks is file header matches to pattern [fast: true, auto-fix: false]

View File

@ -189,7 +189,7 @@ ${RESOURCE_FILE}: ./dist/info.rc ./dist/${SRC_ICO} .FORCE
## Dev dependencies ## Dev dependencies
.PHONY: install-devel-tools install-linter install-go-mod-outdated install-git-hooks .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" LINTSRC:="https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh"
install-dev-dependencies: install-devel-tools install-linter install-go-mod-outdated install-dev-dependencies: install-devel-tools install-linter install-go-mod-outdated

View File

@ -636,7 +636,7 @@ func loadTLSConfig(vault *vault.Vault) (*tls.Config, error) {
}, nil }, nil
} }
func min(a, b time.Duration) time.Duration { func min(a, b time.Duration) time.Duration { //nolint:predeclared
if a < b { if a < b {
return a return a
} }

View File

@ -96,7 +96,7 @@ func (status *ConfigurationStatus) IsPending() bool {
} }
func (status *ConfigurationStatus) isPendingSinceMin() int { 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 min
} }
return 0 return 0
@ -211,7 +211,7 @@ func (data *ConfigurationStatusData) clickedLinkToString() string {
var str = "" var str = ""
var first = true var first = true
for i := 0; i < 64; i++ { for i := 0; i < 64; i++ {
if data.hasLinkClicked(uint64(i)) { if data.hasLinkClicked(uint64(i)) { //nolint:gosec // disable G115
if !first { if !first {
str += "," str += ","
} else { } else {

View File

@ -214,7 +214,10 @@ func NewUserBadEvent(userID string, errorMessage string) *StreamEvent {
} }
func NewUsedBytesChangedEvent(userID string, usedBytes uint64) *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 { func newIMAPLoginFailedEvent(username string) *StreamEvent {

View File

@ -717,8 +717,8 @@ func (s *Service) MailServerSettings(_ context.Context, _ *emptypb.Empty) (*Imap
state: protoimpl.MessageState{}, state: protoimpl.MessageState{},
sizeCache: 0, sizeCache: 0,
unknownFields: nil, unknownFields: nil,
ImapPort: int32(s.bridge.GetIMAPPort()), ImapPort: int32(s.bridge.GetIMAPPort()), //nolint:gosec // disable G115
SmtpPort: int32(s.bridge.GetSMTPPort()), SmtpPort: int32(s.bridge.GetSMTPPort()), //nolint:gosec // disable G115
UseSSLForImap: s.bridge.GetIMAPSSL(), UseSSLForImap: s.bridge.GetIMAPSSL(),
UseSSLForSmtp: s.bridge.GetSMTPSSL(), UseSSLForSmtp: s.bridge.GetSMTPSSL(),
}, nil }, nil
@ -864,8 +864,8 @@ func base64Decode(in []byte) ([]byte, error) {
func (s *Service) getMailServerSettings() *ImapSmtpSettings { func (s *Service) getMailServerSettings() *ImapSmtpSettings {
return &ImapSmtpSettings{ return &ImapSmtpSettings{
ImapPort: int32(s.bridge.GetIMAPPort()), ImapPort: int32(s.bridge.GetIMAPPort()), //nolint:gosec // disable G115
SmtpPort: int32(s.bridge.GetSMTPPort()), SmtpPort: int32(s.bridge.GetSMTPPort()), //nolint:gosec // disable G115
UseSSLForImap: s.bridge.GetIMAPSSL(), UseSSLForImap: s.bridge.GetIMAPSSL(),
UseSSLForSmtp: s.bridge.GetSMTPSSL(), UseSSLForSmtp: s.bridge.GetSMTPSSL(),
} }

View File

@ -71,8 +71,8 @@ func grpcUserFromInfo(user bridge.UserInfo) *User {
AvatarText: getInitials(user.Username), AvatarText: getInitials(user.Username),
State: userStateToGrpc(user.State), State: userStateToGrpc(user.State),
SplitMode: user.AddressMode == vault.SplitMode, SplitMode: user.AddressMode == vault.SplitMode,
UsedBytes: int64(user.UsedSpace), UsedBytes: int64(user.UsedSpace), //nolint:gosec // disable G115
TotalBytes: int64(user.MaxSpace), TotalBytes: int64(user.MaxSpace), //nolint:gosec // disable G115
Password: user.BridgePass, Password: user.BridgePass,
Addresses: user.Addresses, Addresses: user.Addresses,
} }

View File

@ -99,7 +99,7 @@ func GetArticleIndex(url string) (uint64, error) {
if index == -1 { if index == -1 {
return 0, ErrArticleNotFound return 0, ErrArticleNotFound
} }
return uint64(index), nil return uint64(index), nil //nolint:gosec // disable G115
} }
func simplifyUserInput(input string) string { func simplifyUserInput(input string) string {

View File

@ -31,7 +31,7 @@ type CoolDownProvider interface {
Reset() 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 return time.Duration(rand.Intn(max)) * time.Second //nolint:gosec
} }

View File

@ -156,9 +156,9 @@ func newIMAPServer(
func getGluonVersionInfo(version *semver.Version) gluon.Option { func getGluonVersionInfo(version *semver.Version) gluon.Option {
return gluon.WithVersionInfo( return gluon.WithVersionInfo(
int(version.Major()), int(version.Major()), //nolint:gosec // disable G115
int(version.Minor()), int(version.Minor()), //nolint:gosec // disable G115
int(version.Patch()), int(version.Patch()), //nolint:gosec // disable G115
constants.FullAppName, constants.FullAppName,
"TODO", "TODO",
"TODO", "TODO",

View File

@ -114,7 +114,7 @@ func (b *BuildStage) run(ctx context.Context) {
messages: nil, messages: nil,
}); err != nil { }); err != nil {
err = fmt.Errorf("failed to produce output for next stage: %w", err) err = fmt.Errorf("failed to produce output for next stage: %w", err)
logrus.Errorf(err.Error()) logrus.Error(err.Error())
req.job.onError(err) req.job.onError(err)
} }
@ -217,7 +217,7 @@ func chunkSyncBuilderBatch(batch []proton.FullMessage, maxMemory uint64) [][]pro
for _, v := range batch { for _, v := range batch {
var dataSize uint64 var dataSize uint64
for _, a := range v.Attachments { 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 // 2x increase for attachment due to extra memory needed for decrypting and writing

View File

@ -231,7 +231,7 @@ func downloadAttachment(ctx context.Context, cache *DownloadCache, client APICli
} }
type DownloadRateModifier interface { 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]( func autoDownloadRate[T any, R any](
@ -285,7 +285,7 @@ func autoDownloadRate[T any, R any](
type DefaultDownloadRateModifier struct{} 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 { if !wasSuccess {
return 2 return 2
} }

View File

@ -217,7 +217,7 @@ func (m *metadataIterator) Next(maxDownloadMem uint64, metadataPageSize int, max
} }
for idx, meta := range m.remaining { 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 { if nextSize >= maxDownloadMem || len(m.downloadReqIDs) >= maxMessages {
m.expectedSize = 0 m.expectedSize = 0
m.remaining = m.remaining[idx:] m.remaining = m.remaining[idx:]

View File

@ -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 { func (s *Service) HandleUsedSpaceEvent(ctx context.Context, newSpace int64) error {
s.log.Info("Handling User Space Changed event") 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{ s.eventPublisher.PublishEvent(ctx, events.UsedSpaceChanged{
UserID: s.identity.User.ID, UserID: s.identity.User.ID,
UsedSpace: uint64(newSpace), UsedSpace: uint64(newSpace), //nolint:gosec // disable G115
}) })
} }

View File

@ -21,6 +21,7 @@ import (
"bytes" "bytes"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -658,7 +659,7 @@ func (s *scenario) imapClientsMoveMessageWithSubjectUserFromToByOrderedOperation
case "EXPUNGE": case "EXPUNGE":
expungeErr = sourceClient.Expunge(nil) expungeErr = sourceClient.Expunge(nil)
default: default:
return fmt.Errorf("unknown IMAP operation " + op) return errors.New("unknown IMAP operation " + op)
} }
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
} }