From f684abc29f6b80084e1001b1c47234cbbb5b29f8 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 28 Mar 2024 00:15:14 +0100 Subject: [PATCH] Lint: Update linter config, remove no longer required exeptions which might be a false-negative and re-added later Signed-off-by: Knut Ahlers --- .golangci.yml | 4 +++- internal/actors/counter/actor.go | 2 +- internal/actors/punish/actor.go | 2 +- internal/actors/punish/database.go | 2 +- internal/actors/quotedb/actor.go | 2 +- internal/actors/variables/actor.go | 2 +- internal/actors/variables/database.go | 2 +- internal/apimodules/customevent/customevent.go | 2 +- internal/apimodules/overlays/database.go | 2 +- internal/apimodules/overlays/overlays.go | 2 +- internal/apimodules/raffle/raffle.go | 2 +- internal/helpers/retry.go | 2 +- internal/service/access/access.go | 4 ++-- internal/service/timer/timer.go | 2 +- pkg/twitch/eventsubWebsocketClient.go | 2 +- plugins_core.go | 1 - 16 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e4d0cf1..8fb2844 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,7 +9,9 @@ run: modules-download-mode: readonly output: - format: tab + formats: + - format: tab + path: stdout issues: # This disables the included exclude-list in golangci-lint as that diff --git a/internal/actors/counter/actor.go b/internal/actors/counter/actor.go index c5d266f..eb06c05 100644 --- a/internal/actors/counter/actor.go +++ b/internal/actors/counter/actor.go @@ -34,7 +34,7 @@ func Register(args plugins.RegistrationArguments) (err error) { } args.RegisterCopyDatabaseFunc("counter", func(src, target *gorm.DB) error { - return database.CopyObjects(src, target, &counter{}) //nolint:wrapcheck // internal helper + return database.CopyObjects(src, target, &counter{}) }) formatMessage = args.FormatMessage diff --git a/internal/actors/punish/actor.go b/internal/actors/punish/actor.go index 25ce3a3..6b27e15 100644 --- a/internal/actors/punish/actor.go +++ b/internal/actors/punish/actor.go @@ -40,7 +40,7 @@ func Register(args plugins.RegistrationArguments) error { } args.RegisterCopyDatabaseFunc("punish", func(src, target *gorm.DB) error { - return database.CopyObjects(src, target, &punishLevel{}) //nolint:wrapcheck // internal helper + return database.CopyObjects(src, target, &punishLevel{}) }) botTwitchClient = args.GetTwitchClient() diff --git a/internal/actors/punish/database.go b/internal/actors/punish/database.go index 2cf5cbf..e77f1ba 100644 --- a/internal/actors/punish/database.go +++ b/internal/actors/punish/database.go @@ -94,7 +94,7 @@ func getPunishment(db database.Connector, channel, user, uuid string) (*levelCon err := helpers.Retry(func() error { err := db.DB().First(&p, "key = ?", getDBKey(channel, user, uuid)).Error if errors.Is(err, gorm.ErrRecordNotFound) { - return backoff.NewErrCannotRetry(err) //nolint:wrapcheck // we get our internal error + return backoff.NewErrCannotRetry(err) } return err }) diff --git a/internal/actors/quotedb/actor.go b/internal/actors/quotedb/actor.go index 1a9248a..2ffbb2b 100644 --- a/internal/actors/quotedb/actor.go +++ b/internal/actors/quotedb/actor.go @@ -36,7 +36,7 @@ func Register(args plugins.RegistrationArguments) (err error) { } args.RegisterCopyDatabaseFunc("quote", func(src, target *gorm.DB) error { - return database.CopyObjects(src, target, "e{}) //nolint:wrapcheck // internal helper + return database.CopyObjects(src, target, "e{}) }) formatMessage = args.FormatMessage diff --git a/internal/actors/variables/actor.go b/internal/actors/variables/actor.go index 5dc73b7..8b9a4f1 100644 --- a/internal/actors/variables/actor.go +++ b/internal/actors/variables/actor.go @@ -33,7 +33,7 @@ func Register(args plugins.RegistrationArguments) (err error) { } args.RegisterCopyDatabaseFunc("variable", func(src, target *gorm.DB) error { - return database.CopyObjects(src, target, &variable{}) //nolint:wrapcheck // internal helper + return database.CopyObjects(src, target, &variable{}) }) formatMessage = args.FormatMessage diff --git a/internal/actors/variables/database.go b/internal/actors/variables/database.go index e92ed06..760134e 100644 --- a/internal/actors/variables/database.go +++ b/internal/actors/variables/database.go @@ -22,7 +22,7 @@ func getVariable(db database.Connector, key string) (string, error) { err := helpers.Retry(func() error { err := db.DB().First(&v, "name = ?", key).Error if errors.Is(err, gorm.ErrRecordNotFound) { - return backoff.NewErrCannotRetry(err) //nolint:wrapcheck // we get our internal error + return backoff.NewErrCannotRetry(err) } return err }) diff --git a/internal/apimodules/customevent/customevent.go b/internal/apimodules/customevent/customevent.go index d12e586..14c9a7d 100644 --- a/internal/apimodules/customevent/customevent.go +++ b/internal/apimodules/customevent/customevent.go @@ -37,7 +37,7 @@ func Register(args plugins.RegistrationArguments) (err error) { } args.RegisterCopyDatabaseFunc("custom_event", func(src, target *gorm.DB) error { - return database.CopyObjects(src, target, &storedCustomEvent{}) //nolint:wrapcheck // internal helper + return database.CopyObjects(src, target, &storedCustomEvent{}) }) mc = &memoryCache{dbc: db} diff --git a/internal/apimodules/overlays/database.go b/internal/apimodules/overlays/database.go index 33cedb5..7dba886 100644 --- a/internal/apimodules/overlays/database.go +++ b/internal/apimodules/overlays/database.go @@ -75,7 +75,7 @@ func getEventByID(db database.Connector, eventID uint64) (socketMessage, error) if err := helpers.Retry(func() (err error) { err = db.DB().Where("id = ?", eventID).First(&evt).Error if errors.Is(err, gorm.ErrRecordNotFound) { - return backoff.NewErrCannotRetry(err) //nolint:wrapcheck // we get our internal error + return backoff.NewErrCannotRetry(err) } return err }); err != nil { diff --git a/internal/apimodules/overlays/overlays.go b/internal/apimodules/overlays/overlays.go index 323a92e..423a79b 100644 --- a/internal/apimodules/overlays/overlays.go +++ b/internal/apimodules/overlays/overlays.go @@ -92,7 +92,7 @@ func Register(args plugins.RegistrationArguments) (err error) { } args.RegisterCopyDatabaseFunc("overlay_events", func(src, target *gorm.DB) error { - return database.CopyObjects(src, target, &overlaysEvent{}) //nolint:wrapcheck // internal helper + return database.CopyObjects(src, target, &overlaysEvent{}) }) validateToken = args.ValidateToken diff --git a/internal/apimodules/raffle/raffle.go b/internal/apimodules/raffle/raffle.go index b5c304a..879c588 100644 --- a/internal/apimodules/raffle/raffle.go +++ b/internal/apimodules/raffle/raffle.go @@ -29,7 +29,7 @@ func Register(args plugins.RegistrationArguments) (err error) { } args.RegisterCopyDatabaseFunc("raffle", func(src, target *gorm.DB) error { - return database.CopyObjects(src, target, &raffle{}, &raffleEntry{}) //nolint:wrapcheck // internal helper + return database.CopyObjects(src, target, &raffle{}, &raffleEntry{}) }) dbc = newDBClient(db) diff --git a/internal/helpers/retry.go b/internal/helpers/retry.go index 99156c5..3246129 100644 --- a/internal/helpers/retry.go +++ b/internal/helpers/retry.go @@ -23,6 +23,6 @@ func Retry(fn func() error) error { // database and will be retried as if executed using Retry func RetryTransaction(db *gorm.DB, fn func(tx *gorm.DB) error) error { return Retry(func() error { - return db.Transaction(fn) //nolint:wrapcheck + return db.Transaction(fn) }) } diff --git a/internal/service/access/access.go b/internal/service/access/access.go index d6030a0..fd6269c 100644 --- a/internal/service/access/access.go +++ b/internal/service/access/access.go @@ -172,7 +172,7 @@ func (s Service) GetTwitchClientForChannel(channel string, cfg ClientConfig) (*t if err = helpers.Retry(func() error { err = s.db.DB().First(&perm, "channel = ?", strings.TrimLeft(channel, "#")).Error if errors.Is(err, gorm.ErrRecordNotFound) { - return backoff.NewErrCannotRetry(ErrChannelNotAuthorized) //nolint:wrapcheck // We get our own error + return backoff.NewErrCannotRetry(ErrChannelNotAuthorized) } return errors.Wrap(err, "getting twitch credential from database") }); err != nil { @@ -251,7 +251,7 @@ func (s Service) HasTokensForChannel(channel string) (bool, error) { if err = helpers.Retry(func() error { err = s.db.DB().First(&perm, "channel = ?", strings.TrimLeft(channel, "#")).Error if errors.Is(err, gorm.ErrRecordNotFound) { - return backoff.NewErrCannotRetry(ErrChannelNotAuthorized) //nolint:wrapcheck // We'll get our own error + return backoff.NewErrCannotRetry(ErrChannelNotAuthorized) } return errors.Wrap(err, "getting twitch credential from database") }); err != nil { diff --git a/internal/service/timer/timer.go b/internal/service/timer/timer.go index e4aa0ac..063dd60 100644 --- a/internal/service/timer/timer.go +++ b/internal/service/timer/timer.go @@ -103,7 +103,7 @@ func (s Service) HasTimer(id string) (bool, error) { err := helpers.Retry(func() error { err := s.db.DB().First(&t, "id = ? AND expires_at >= ?", id, time.Now().UTC()).Error if errors.Is(err, gorm.ErrRecordNotFound) { - return backoff.NewErrCannotRetry(err) //nolint:wrapcheck // We'll get our own error + return backoff.NewErrCannotRetry(err) } return err }) diff --git a/pkg/twitch/eventsubWebsocketClient.go b/pkg/twitch/eventsubWebsocketClient.go index ffc04d6..9bdbc3a 100644 --- a/pkg/twitch/eventsubWebsocketClient.go +++ b/pkg/twitch/eventsubWebsocketClient.go @@ -445,7 +445,7 @@ func (e *EventSubSocketClient) retryBackgroundSubscribe(st eventSubSocketSubscri if err := e.runCtx.Err(); err != nil { // Our run-context was cancelled, stop retrying to subscribe // to topics as this client was closed - return backoff.NewErrCannotRetry(err) //nolint:wrapcheck // We get our internal error + return backoff.NewErrCannotRetry(err) } return e.subscribe(st) diff --git a/plugins_core.go b/plugins_core.go index 24718e8..8cd61c8 100644 --- a/plugins_core.go +++ b/plugins_core.go @@ -189,7 +189,6 @@ func getRegistrationArguments() plugins.RegistrationArguments { }, GetTwitchClientForChannel: func(channel string) (*twitch.Client, error) { - //nolint:wrapcheck // own package, no need to wrap return accessService.GetTwitchClientForChannel(channel, access.ClientConfig{ TwitchClient: cfg.TwitchClient, TwitchClientSecret: cfg.TwitchClientSecret,