From 286c4d34a3ede2ea0fefa35d7c46dece9cdac3ba Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Fri, 24 Mar 2023 22:32:00 +0100 Subject: [PATCH] Lint: Fix linter errors made visible after update of golangci-lint Signed-off-by: Knut Ahlers --- .golangci.yml | 5 +++++ action_script.go | 8 +++---- automessage.go | 2 +- configEditor_automessage.go | 2 +- configEditor_general.go | 6 ++--- configEditor_global.go | 4 ++-- configEditor_rules.go | 2 +- functions_test.go | 2 +- functions_twitch.go | 2 +- internal/actors/ban/actor.go | 2 +- internal/actors/commercial/actor.go | 2 +- internal/actors/counter/actor.go | 2 +- internal/actors/delay/actor.go | 2 +- internal/actors/delete/actor.go | 2 +- internal/actors/eventmod/actor.go | 2 +- internal/actors/filesay/actor.go | 2 +- internal/actors/log/actor.go | 2 +- internal/actors/modchannel/actor.go | 2 +- internal/actors/nuke/actions.go | 4 ++-- internal/actors/nuke/actor.go | 2 +- internal/actors/punish/actor.go | 4 ++-- internal/actors/quotedb/actor.go | 2 +- internal/actors/quotedb/http.go | 2 +- internal/actors/raw/actor.go | 2 +- internal/actors/respond/actor.go | 2 +- internal/actors/shield/actor.go | 4 ++-- internal/actors/shoutout/actor.go | 2 +- internal/actors/stopexec/actor.go | 2 +- internal/actors/timeout/actor.go | 2 +- internal/actors/variables/actor.go | 2 +- internal/actors/vip/vip.go | 4 ++-- internal/actors/whisper/actor.go | 2 +- internal/apimodules/customevent/actor.go | 2 +- msgformatter.go | 4 ++-- plugins/fieldcollection_test.go | 4 ++-- plugins/rule.go | 28 ++++++++++++------------ swagger.go | 4 ++-- 37 files changed, 67 insertions(+), 62 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a36c168..114e9c4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,6 +11,11 @@ run: output: format: tab +issues: + # Don't limit the number of shown issues: Report ALL of them + max-issues-per-linter: 0 + max-same-issues: 0 + linters-settings: forbidigo: forbid: diff --git a/action_script.go b/action_script.go index 4eb0ace..d642c04 100644 --- a/action_script.go +++ b/action_script.go @@ -47,7 +47,7 @@ func init() { type ActorScript struct{} -func (a ActorScript) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (ActorScript) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { command, err := attrs.StringSlice("command") if err != nil { return false, errors.Wrap(err, "getting command") @@ -121,10 +121,10 @@ func (a ActorScript) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eve return preventCooldown, nil } -func (a ActorScript) IsAsync() bool { return false } -func (a ActorScript) Name() string { return "script" } +func (ActorScript) IsAsync() bool { return false } +func (ActorScript) Name() string { return "script" } -func (a ActorScript) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *plugins.FieldCollection) (err error) { +func (ActorScript) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *plugins.FieldCollection) (err error) { cmd, err := attrs.StringSlice("command") if err != nil || len(cmd) == 0 { return errors.New("command must be slice of strings with length > 0") diff --git a/automessage.go b/automessage.go index 2b9b229..5da68e2 100644 --- a/automessage.go +++ b/automessage.go @@ -138,7 +138,7 @@ func (a *autoMessage) IsValid() bool { return true } -func (a *autoMessage) Send(c *irc.Client) error { +func (a *autoMessage) Send(_ *irc.Client) error { a.lock.Lock() defer a.lock.Unlock() diff --git a/configEditor_automessage.go b/configEditor_automessage.go index 9847974..372f3e9 100644 --- a/configEditor_automessage.go +++ b/configEditor_automessage.go @@ -132,7 +132,7 @@ func configEditorHandleAutoMessageDelete(w http.ResponseWriter, r *http.Request) w.WriteHeader(http.StatusNoContent) } -func configEditorHandleAutoMessagesGet(w http.ResponseWriter, r *http.Request) { +func configEditorHandleAutoMessagesGet(w http.ResponseWriter, _ *http.Request) { if err := json.NewEncoder(w).Encode(config.AutoMessages); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/configEditor_general.go b/configEditor_general.go index 4b618e0..73433d8 100644 --- a/configEditor_general.go +++ b/configEditor_general.go @@ -133,7 +133,7 @@ func configEditorHandleGeneralAddAuthToken(w http.ResponseWriter, r *http.Reques } } -func configEditorHandleGeneralAuthURLs(w http.ResponseWriter, r *http.Request) { +func configEditorHandleGeneralAuthURLs(w http.ResponseWriter, _ *http.Request) { var out struct { AvailableExtendedScopes map[string]string `json:"available_extended_scopes"` UpdateBotToken string `json:"update_bot_token"` @@ -185,7 +185,7 @@ func configEditorHandleGeneralDeleteAuthToken(w http.ResponseWriter, r *http.Req w.WriteHeader(http.StatusNoContent) } -func configEditorHandleGeneralGet(w http.ResponseWriter, r *http.Request) { +func configEditorHandleGeneralGet(w http.ResponseWriter, _ *http.Request) { channelScopes := make(map[string][]string) channels, err := accessService.ListPermittedChannels() @@ -217,7 +217,7 @@ func configEditorHandleGeneralGet(w http.ResponseWriter, r *http.Request) { } } -func configEditorHandleGeneralListAuthTokens(w http.ResponseWriter, r *http.Request) { +func configEditorHandleGeneralListAuthTokens(w http.ResponseWriter, _ *http.Request) { if err := json.NewEncoder(w).Encode(config.AuthTokens); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/configEditor_global.go b/configEditor_global.go index 266f996..bd1bbb8 100644 --- a/configEditor_global.go +++ b/configEditor_global.go @@ -107,7 +107,7 @@ func registerEditorGlobalMethods() { } } -func configEditorGlobalGetActions(w http.ResponseWriter, r *http.Request) { +func configEditorGlobalGetActions(w http.ResponseWriter, _ *http.Request) { availableActorDocsLock.Lock() defer availableActorDocsLock.Unlock() @@ -116,7 +116,7 @@ func configEditorGlobalGetActions(w http.ResponseWriter, r *http.Request) { } } -func configEditorGlobalGetModules(w http.ResponseWriter, r *http.Request) { +func configEditorGlobalGetModules(w http.ResponseWriter, _ *http.Request) { if err := json.NewEncoder(w).Encode(knownModules); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/configEditor_rules.go b/configEditor_rules.go index 025df01..c6a8581 100644 --- a/configEditor_rules.go +++ b/configEditor_rules.go @@ -145,7 +145,7 @@ func configEditorRulesDelete(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) } -func configEditorRulesGet(w http.ResponseWriter, r *http.Request) { +func configEditorRulesGet(w http.ResponseWriter, _ *http.Request) { if err := json.NewEncoder(w).Encode(config.Rules); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/functions_test.go b/functions_test.go index 996dabb..1beb048 100644 --- a/functions_test.go +++ b/functions_test.go @@ -2,6 +2,6 @@ package main import "testing" -func TestNoFuncCollisions(t *testing.T) { +func TestNoFuncCollisions(_ *testing.T) { _ = tplFuncs.GetFuncMap(nil, nil, nil) } diff --git a/functions_twitch.go b/functions_twitch.go index ca7520b..5729841 100644 --- a/functions_twitch.go +++ b/functions_twitch.go @@ -24,7 +24,7 @@ func init() { func tplTwitchDisplayName(username string, v ...string) (string, error) { displayName, err := twitchClient.GetDisplayNameForUser(strings.TrimLeft(username, "#")) if len(v) > 0 && (err != nil || displayName == "") { - return v[0], nil + return v[0], nil //nolint:nilerr // Default value, no need to return error } return displayName, err diff --git a/internal/actors/ban/actor.go b/internal/actors/ban/actor.go index 375f388..c98a94c 100644 --- a/internal/actors/ban/actor.go +++ b/internal/actors/ban/actor.go @@ -81,7 +81,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { ptrStringEmpty := func(v string) *string { return &v }("") reason, err := formatMessage(attrs.MustString("reason", ptrStringEmpty), m, r, eventData) diff --git a/internal/actors/commercial/actor.go b/internal/actors/commercial/actor.go index f5fb250..c256676 100644 --- a/internal/actors/commercial/actor.go +++ b/internal/actors/commercial/actor.go @@ -59,7 +59,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { ptrStringEmpty := func(v string) *string { return &v }("") durationStr, err := formatMessage(attrs.MustString("duration", ptrStringEmpty), m, r, eventData) diff --git a/internal/actors/counter/actor.go b/internal/actors/counter/actor.go index fcba46c..8d590bf 100644 --- a/internal/actors/counter/actor.go +++ b/internal/actors/counter/actor.go @@ -142,7 +142,7 @@ func Register(args plugins.RegistrationArguments) error { type ActorCounter struct{} -func (a ActorCounter) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a ActorCounter) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { counterName, err := formatMessage(attrs.MustString("counter", nil), m, r, eventData) if err != nil { return false, errors.Wrap(err, "preparing response") diff --git a/internal/actors/delay/actor.go b/internal/actors/delay/actor.go index 29b538c..703eff4 100644 --- a/internal/actors/delay/actor.go +++ b/internal/actors/delay/actor.go @@ -46,7 +46,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, _ *irc.Message, _ *plugins.Rule, _ *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { var ( ptrZeroDuration = func(v time.Duration) *time.Duration { return &v }(0) delay = attrs.MustDuration("delay", ptrZeroDuration) diff --git a/internal/actors/delete/actor.go b/internal/actors/delete/actor.go index 3d179de..c39ade1 100644 --- a/internal/actors/delete/actor.go +++ b/internal/actors/delete/actor.go @@ -28,7 +28,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, _ *plugins.Rule, eventData *plugins.FieldCollection, _ *plugins.FieldCollection) (preventCooldown bool, err error) { msgID, ok := m.Tags.GetTag("id") if !ok || msgID == "" { return false, nil diff --git a/internal/actors/eventmod/actor.go b/internal/actors/eventmod/actor.go index 174d0f7..487d092 100644 --- a/internal/actors/eventmod/actor.go +++ b/internal/actors/eventmod/actor.go @@ -41,7 +41,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { ptrStringEmpty := func(v string) *string { return &v }("") fd, err := formatMessage(attrs.MustString("fields", ptrStringEmpty), m, r, eventData) diff --git a/internal/actors/filesay/actor.go b/internal/actors/filesay/actor.go index 2d5fb32..b2db762 100644 --- a/internal/actors/filesay/actor.go +++ b/internal/actors/filesay/actor.go @@ -53,7 +53,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { ptrStringEmpty := func(v string) *string { return &v }("") source, err := formatMessage(attrs.MustString("source", ptrStringEmpty), m, r, eventData) diff --git a/internal/actors/log/actor.go b/internal/actors/log/actor.go index 3b21ea8..c7adcc8 100644 --- a/internal/actors/log/actor.go +++ b/internal/actors/log/actor.go @@ -42,7 +42,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { message, err := formatMessage(attrs.MustString("message", ptrStringEmpty), m, r, eventData) if err != nil { return false, errors.Wrap(err, "executing message template") diff --git a/internal/actors/modchannel/actor.go b/internal/actors/modchannel/actor.go index 95502aa..26ef971 100644 --- a/internal/actors/modchannel/actor.go +++ b/internal/actors/modchannel/actor.go @@ -67,7 +67,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { var ( game = attrs.MustString("game", ptrStringEmpty) title = attrs.MustString("title", ptrStringEmpty) diff --git a/internal/actors/nuke/actions.go b/internal/actors/nuke/actions.go index 3f13da2..46c4262 100644 --- a/internal/actors/nuke/actions.go +++ b/internal/actors/nuke/actions.go @@ -11,7 +11,7 @@ type ( actionFn func(channel, match, msgid, user string) error ) -func actionBan(channel, match, msgid, user string) error { +func actionBan(channel, match, _, user string) error { return errors.Wrap( botTwitchClient.BanUser( channel, @@ -23,7 +23,7 @@ func actionBan(channel, match, msgid, user string) error { ) } -func actionDelete(channel, match, msgid, user string) (err error) { +func actionDelete(channel, _, msgid, _ string) (err error) { return errors.Wrap( botTwitchClient.DeleteMessage( channel, diff --git a/internal/actors/nuke/actor.go b/internal/actors/nuke/actor.go index c451e4d..ce6cbd3 100644 --- a/internal/actors/nuke/actor.go +++ b/internal/actors/nuke/actor.go @@ -146,7 +146,7 @@ type ( } ) -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { rawMatch, err := formatMessage(attrs.MustString("match", nil), m, r, eventData) if err != nil { return false, errors.Wrap(err, "formatting match") diff --git a/internal/actors/punish/actor.go b/internal/actors/punish/actor.go index 5e30573..51377f5 100644 --- a/internal/actors/punish/actor.go +++ b/internal/actors/punish/actor.go @@ -138,7 +138,7 @@ type ( // Punish -func (a actorPunish) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actorPunish) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { var ( cooldown = attrs.MustDuration("cooldown", ptrDefaultCooldown) reason = attrs.MustString("reason", ptrStringEmpty) @@ -232,7 +232,7 @@ func (a actorPunish) Validate(tplValidator plugins.TemplateValidatorFunc, attrs // Reset -func (a actorResetPunish) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actorResetPunish) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { var ( user = attrs.MustString("user", nil) uuid = attrs.MustString("uuid", ptrStringEmpty) diff --git a/internal/actors/quotedb/actor.go b/internal/actors/quotedb/actor.go index 1919b30..9c29192 100644 --- a/internal/actors/quotedb/actor.go +++ b/internal/actors/quotedb/actor.go @@ -96,7 +96,7 @@ type ( actor struct{} ) -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { var ( action = attrs.MustString("action", ptrStringEmpty) indexStr = attrs.MustString("index", ptrStringZero) diff --git a/internal/actors/quotedb/http.go b/internal/actors/quotedb/http.go index 0640c51..dc40130 100644 --- a/internal/actors/quotedb/http.go +++ b/internal/actors/quotedb/http.go @@ -200,7 +200,7 @@ func handleReplaceQuotes(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) } -func handleScript(w http.ResponseWriter, r *http.Request) { +func handleScript(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "text/javascript") w.Write(listScript) } diff --git a/internal/actors/raw/actor.go b/internal/actors/raw/actor.go index ec342e1..d753a67 100644 --- a/internal/actors/raw/actor.go +++ b/internal/actors/raw/actor.go @@ -45,7 +45,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { rawMsg, err := formatMessage(attrs.MustString("message", nil), m, r, eventData) if err != nil { return false, errors.Wrap(err, "preparing raw message") diff --git a/internal/actors/respond/actor.go b/internal/actors/respond/actor.go index c394782..e855d2c 100644 --- a/internal/actors/respond/actor.go +++ b/internal/actors/respond/actor.go @@ -78,7 +78,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { msg, err := formatMessage(attrs.MustString("message", nil), m, r, eventData) if err != nil { if !attrs.CanString("fallback") || attrs.MustString("fallback", nil) == "" { diff --git a/internal/actors/shield/actor.go b/internal/actors/shield/actor.go index 85260ef..0bbc669 100644 --- a/internal/actors/shield/actor.go +++ b/internal/actors/shield/actor.go @@ -42,7 +42,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, _ *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { ptrBoolFalse := func(v bool) *bool { return &v }(false) return false, errors.Wrap( @@ -58,7 +58,7 @@ func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData func (a actor) IsAsync() bool { return false } func (a actor) Name() string { return actorName } -func (a actor) Validate(tplValidator plugins.TemplateValidatorFunc, attrs *plugins.FieldCollection) (err error) { +func (a actor) Validate(_ plugins.TemplateValidatorFunc, attrs *plugins.FieldCollection) (err error) { if _, err = attrs.Bool("enable"); err != nil { return errors.New("enable must be boolean") } diff --git a/internal/actors/shoutout/actor.go b/internal/actors/shoutout/actor.go index d294f41..5ee81e6 100644 --- a/internal/actors/shoutout/actor.go +++ b/internal/actors/shoutout/actor.go @@ -51,7 +51,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { user, err := formatMessage(attrs.MustString("user", ptrStringEmpty), m, r, eventData) if err != nil { return false, errors.Wrap(err, "executing user template") diff --git a/internal/actors/stopexec/actor.go b/internal/actors/stopexec/actor.go index 6dd7e57..5e1a959 100644 --- a/internal/actors/stopexec/actor.go +++ b/internal/actors/stopexec/actor.go @@ -39,7 +39,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { ptrStringEmpty := func(v string) *string { return &v }("") when, err := formatMessage(attrs.MustString("when", ptrStringEmpty), m, r, eventData) diff --git a/internal/actors/timeout/actor.go b/internal/actors/timeout/actor.go index 4eb98bb..d807378 100644 --- a/internal/actors/timeout/actor.go +++ b/internal/actors/timeout/actor.go @@ -62,7 +62,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { reason, err := formatMessage(attrs.MustString("reason", ptrStringEmpty), m, r, eventData) if err != nil { return false, errors.Wrap(err, "executing reason template") diff --git a/internal/actors/variables/actor.go b/internal/actors/variables/actor.go index 9a1ccb9..35a20e3 100644 --- a/internal/actors/variables/actor.go +++ b/internal/actors/variables/actor.go @@ -123,7 +123,7 @@ func Register(args plugins.RegistrationArguments) error { type ActorSetVariable struct{} -func (a ActorSetVariable) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a ActorSetVariable) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { varName, err := formatMessage(attrs.MustString("variable", nil), m, r, eventData) if err != nil { return false, errors.Wrap(err, "preparing variable name") diff --git a/internal/actors/vip/vip.go b/internal/actors/vip/vip.go index 9434c19..0fd2a81 100644 --- a/internal/actors/vip/vip.go +++ b/internal/actors/vip/vip.go @@ -122,7 +122,7 @@ func (a actor) getParams(m *irc.Message, r *plugins.Rule, eventData *plugins.Fie return strings.TrimLeft(channel, "#"), user, nil } -func (u unvipActor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (u unvipActor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { channel, user, err := u.getParams(m, r, eventData, attrs) if err != nil { return false, errors.Wrap(err, "getting parameters") @@ -136,7 +136,7 @@ func (u unvipActor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, even func (unvipActor) Name() string { return "unvip" } -func (v vipActor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (v vipActor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { channel, user, err := v.getParams(m, r, eventData, attrs) if err != nil { return false, errors.Wrap(err, "getting parameters") diff --git a/internal/actors/whisper/actor.go b/internal/actors/whisper/actor.go index 5834df0..aee4a38 100644 --- a/internal/actors/whisper/actor.go +++ b/internal/actors/whisper/actor.go @@ -55,7 +55,7 @@ func Register(args plugins.RegistrationArguments) error { type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { to, err := formatMessage(attrs.MustString("to", nil), m, r, eventData) if err != nil { return false, errors.Wrap(err, "preparing whisper receiver") diff --git a/internal/apimodules/customevent/actor.go b/internal/apimodules/customevent/actor.go index b32f92e..96ef13f 100644 --- a/internal/apimodules/customevent/actor.go +++ b/internal/apimodules/customevent/actor.go @@ -11,7 +11,7 @@ import ( type actor struct{} -func (a actor) Execute(c *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { +func (a actor) Execute(_ *irc.Client, m *irc.Message, r *plugins.Rule, eventData *plugins.FieldCollection, attrs *plugins.FieldCollection) (preventCooldown bool, err error) { fd, err := formatMessage(attrs.MustString("fields", ptrStringEmpty), m, r, eventData) if err != nil { return false, errors.Wrap(err, "executing fields template") diff --git a/msgformatter.go b/msgformatter.go index 99eb6d3..b038736 100644 --- a/msgformatter.go +++ b/msgformatter.go @@ -65,7 +65,7 @@ func formatMessageFieldChannel(compiledFields *plugins.FieldCollection, m *irc.M compiledFields.Set(eventFieldChannel, plugins.DeriveChannel(m, fields)) } -func formatMessageFieldMessage(compiledFields *plugins.FieldCollection, m *irc.Message, fields *plugins.FieldCollection) { +func formatMessageFieldMessage(compiledFields *plugins.FieldCollection, m *irc.Message, _ *plugins.FieldCollection) { if m == nil { return } @@ -73,7 +73,7 @@ func formatMessageFieldMessage(compiledFields *plugins.FieldCollection, m *irc.M compiledFields.Set("msg", m) } -func formatMessageFieldUserID(compiledFields *plugins.FieldCollection, m *irc.Message, fields *plugins.FieldCollection) { +func formatMessageFieldUserID(compiledFields *plugins.FieldCollection, m *irc.Message, _ *plugins.FieldCollection) { if m == nil { return } diff --git a/plugins/fieldcollection_test.go b/plugins/fieldcollection_test.go index 361af30..b078df8 100644 --- a/plugins/fieldcollection_test.go +++ b/plugins/fieldcollection_test.go @@ -49,7 +49,7 @@ func TestFieldCollectionYAMLMarshal(t *testing.T) { } } -func TestFieldCollectionNilModify(t *testing.T) { +func TestFieldCollectionNilModify(_ *testing.T) { var f *FieldCollection f.Set("foo", "bar") @@ -58,7 +58,7 @@ func TestFieldCollectionNilModify(t *testing.T) { f.SetFromData(map[string]interface{}{"foo": "bar"}) } -func TestFieldCollectionNilClone(t *testing.T) { +func TestFieldCollectionNilClone(_ *testing.T) { var f *FieldCollection f.Clone() diff --git a/plugins/rule.go b/plugins/rule.go index 33bca0c..fe8b5e4 100644 --- a/plugins/rule.go +++ b/plugins/rule.go @@ -224,7 +224,7 @@ func (r Rule) Validate(tplValidate TemplateValidatorFunc) error { return nil } -func (r *Rule) allowExecuteBadgeBlacklist(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteBadgeBlacklist(logger *log.Entry, _ *irc.Message, _ *string, badges twitch.BadgeCollection, _ *FieldCollection) bool { for _, b := range r.DisableOn { if badges.Has(b) { logger.Tracef("Non-Match: Disable-Badge %s", b) @@ -235,7 +235,7 @@ func (r *Rule) allowExecuteBadgeBlacklist(logger *log.Entry, m *irc.Message, eve return true } -func (r *Rule) allowExecuteBadgeWhitelist(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteBadgeWhitelist(_ *log.Entry, _ *irc.Message, _ *string, badges twitch.BadgeCollection, _ *FieldCollection) bool { if len(r.EnableOn) == 0 { // No match criteria set, does not speak against matching return true @@ -250,7 +250,7 @@ func (r *Rule) allowExecuteBadgeWhitelist(logger *log.Entry, m *irc.Message, eve return false } -func (r *Rule) allowExecuteChannelCooldown(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteChannelCooldown(logger *log.Entry, m *irc.Message, _ *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { if r.ChannelCooldown == nil || DeriveChannel(m, evtData) == "" { // No match criteria set, does not speak against matching return true @@ -275,7 +275,7 @@ func (r *Rule) allowExecuteChannelCooldown(logger *log.Entry, m *irc.Message, ev return false } -func (r *Rule) allowExecuteChannelWhitelist(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteChannelWhitelist(logger *log.Entry, m *irc.Message, _ *string, _ twitch.BadgeCollection, evtData *FieldCollection) bool { if len(r.MatchChannels) == 0 { // No match criteria set, does not speak against matching return true @@ -289,7 +289,7 @@ func (r *Rule) allowExecuteChannelWhitelist(logger *log.Entry, m *irc.Message, e return true } -func (r *Rule) allowExecuteDisable(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteDisable(logger *log.Entry, _ *irc.Message, _ *string, _ twitch.BadgeCollection, _ *FieldCollection) bool { if r.Disable == nil { // No match criteria set, does not speak against matching return true @@ -303,7 +303,7 @@ func (r *Rule) allowExecuteDisable(logger *log.Entry, m *irc.Message, event *str return true } -func (r *Rule) allowExecuteDisableOnOffline(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteDisableOnOffline(logger *log.Entry, m *irc.Message, _ *string, _ twitch.BadgeCollection, evtData *FieldCollection) bool { if r.DisableOnOffline == nil || !*r.DisableOnOffline || DeriveChannel(m, evtData) == "" { // No match criteria set, does not speak against matching return true @@ -322,7 +322,7 @@ func (r *Rule) allowExecuteDisableOnOffline(logger *log.Entry, m *irc.Message, e return true } -func (r *Rule) allowExecuteDisableOnPermit(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteDisableOnPermit(logger *log.Entry, m *irc.Message, _ *string, _ twitch.BadgeCollection, evtData *FieldCollection) bool { hasPermit, err := r.timerStore.HasPermit(DeriveChannel(m, evtData), DeriveUser(m, evtData)) if err != nil { logger.WithError(err).Error("checking permit") @@ -337,7 +337,7 @@ func (r *Rule) allowExecuteDisableOnPermit(logger *log.Entry, m *irc.Message, ev return true } -func (r *Rule) allowExecuteDisableOnTemplate(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteDisableOnTemplate(logger *log.Entry, m *irc.Message, _ *string, _ twitch.BadgeCollection, evtData *FieldCollection) bool { if r.DisableOnTemplate == nil || *r.DisableOnTemplate == "" { // No match criteria set, does not speak against matching return true @@ -358,7 +358,7 @@ func (r *Rule) allowExecuteDisableOnTemplate(logger *log.Entry, m *irc.Message, return true } -func (r *Rule) allowExecuteEventWhitelist(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteEventWhitelist(logger *log.Entry, _ *irc.Message, event *string, _ twitch.BadgeCollection, _ *FieldCollection) bool { if r.MatchEvent == nil || *r.MatchEvent == "" { // No match criteria set, does not speak against matching return true @@ -372,7 +372,7 @@ func (r *Rule) allowExecuteEventWhitelist(logger *log.Entry, m *irc.Message, eve return true } -func (r *Rule) allowExecuteMessageMatcherBlacklist(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteMessageMatcherBlacklist(logger *log.Entry, m *irc.Message, _ *string, _ twitch.BadgeCollection, _ *FieldCollection) bool { if len(r.DisableOnMatchMessages) == 0 { // No match criteria set, does not speak against matching return true @@ -401,7 +401,7 @@ func (r *Rule) allowExecuteMessageMatcherBlacklist(logger *log.Entry, m *irc.Mes return true } -func (r *Rule) allowExecuteMessageMatcherWhitelist(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteMessageMatcherWhitelist(logger *log.Entry, m *irc.Message, _ *string, _ twitch.BadgeCollection, _ *FieldCollection) bool { if r.MatchMessage == nil { // No match criteria set, does not speak against matching return true @@ -426,7 +426,7 @@ func (r *Rule) allowExecuteMessageMatcherWhitelist(logger *log.Entry, m *irc.Mes return true } -func (r *Rule) allowExecuteRuleCooldown(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteRuleCooldown(logger *log.Entry, _ *irc.Message, _ *string, badges twitch.BadgeCollection, _ *FieldCollection) bool { if r.Cooldown == nil { // No match criteria set, does not speak against matching return true @@ -451,7 +451,7 @@ func (r *Rule) allowExecuteRuleCooldown(logger *log.Entry, m *irc.Message, event return false } -func (r *Rule) allowExecuteUserCooldown(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteUserCooldown(logger *log.Entry, m *irc.Message, _ *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { if r.UserCooldown == nil { // No match criteria set, does not speak against matching return true @@ -476,7 +476,7 @@ func (r *Rule) allowExecuteUserCooldown(logger *log.Entry, m *irc.Message, event return false } -func (r *Rule) allowExecuteUserWhitelist(logger *log.Entry, m *irc.Message, event *string, badges twitch.BadgeCollection, evtData *FieldCollection) bool { +func (r *Rule) allowExecuteUserWhitelist(logger *log.Entry, m *irc.Message, _ *string, _ twitch.BadgeCollection, evtData *FieldCollection) bool { if len(r.MatchUsers) == 0 { // No match criteria set, does not speak against matching return true diff --git a/swagger.go b/swagger.go index 4c8adea..9d25d01 100644 --- a/swagger.go +++ b/swagger.go @@ -52,7 +52,7 @@ func init() { } } -func handleSwaggerHTML(w http.ResponseWriter, r *http.Request) { +func handleSwaggerHTML(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "text/html") if _, err := io.Copy(w, bytes.NewReader(swaggerHTML)); err != nil { @@ -60,7 +60,7 @@ func handleSwaggerHTML(w http.ResponseWriter, r *http.Request) { } } -func handleSwaggerRequest(w http.ResponseWriter, r *http.Request) { +func handleSwaggerRequest(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(swaggerDoc); err != nil {