From 9b0b09b4e232cf1554744506e96bf8b785e2b217 Mon Sep 17 00:00:00 2001 From: wass3rw3rk <49894298+wass3rw3rk@users.noreply.github.com> Date: Fri, 5 May 2023 16:34:41 -0500 Subject: [PATCH] the linter has spoken --- core/matcher.go | 4 ++-- remote/cli/remote.go | 4 ++-- remote/discord/remote.go | 4 ++-- remote/gchat/remote.go | 6 +++--- remote/scheduler/remote.go | 4 ++-- remote/slack/helper.go | 3 +-- remote/slack/remote.go | 6 +++--- remote/telegram/remote.go | 6 +++--- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/core/matcher.go b/core/matcher.go index acc01cbf..40cbcb40 100644 --- a/core/matcher.go +++ b/core/matcher.go @@ -334,8 +334,8 @@ func doRuleActions(message models.Message, outputMsgs chan<- models.Message, rul directive = false } // Create copy of message so as to not overwrite other message action type messages - copy := deepcopy.Copy(message).(models.Message) - err = handleMessage(action, outputMsgs, ©, directive, rule.StartMessageThread, hitRule, bot) + dcopy := deepcopy.Copy(message).(models.Message) + err = handleMessage(action, outputMsgs, &dcopy, directive, rule.StartMessageThread, hitRule, bot) // Fallback to error if action type is invalid default: log.Error().Msgf("the rule %#q of type %#q is not a supported action", action.Name, action.Type) diff --git a/remote/cli/remote.go b/remote/cli/remote.go index 556db7e6..5a6af605 100644 --- a/remote/cli/remote.go +++ b/remote/cli/remote.go @@ -30,12 +30,12 @@ func (c *Client) Name() string { } // Reaction implementation to satisfy remote interface. -func (c *Client) Reaction(message models.Message, rule models.Rule, bot *models.Bot) { +func (c *Client) Reaction(_ models.Message, _ models.Rule, _ *models.Bot) { // not implemented for CLI } // Read implementation to satisfy remote interface. -func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.Rule, bot *models.Bot) { +func (c *Client) Read(inputMsgs chan<- models.Message, _ map[string]models.Rule, bot *models.Bot) { user := bot.CLIUser if user == "" { user = "Flottbot-CLI-User" diff --git a/remote/discord/remote.go b/remote/discord/remote.go index 6124fbcf..9ae6baf7 100644 --- a/remote/discord/remote.go +++ b/remote/discord/remote.go @@ -49,7 +49,7 @@ func (c *Client) Name() string { // . // reaction: 🔥 // . -func (c *Client) Reaction(message models.Message, rule models.Rule, bot *models.Bot) { +func (c *Client) Reaction(message models.Message, rule models.Rule, _ *models.Bot) { if rule.RemoveReaction != "" { // Init api client dg := c.new() @@ -76,7 +76,7 @@ func (c *Client) Reaction(message models.Message, rule models.Rule, bot *models. } // Read implementation to satisfy remote interface. -func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.Rule, bot *models.Bot) { +func (c *Client) Read(inputMsgs chan<- models.Message, _ map[string]models.Rule, bot *models.Bot) { dg := c.new() if dg == nil { log.Error().Msg("failed to initialize discord client") diff --git a/remote/gchat/remote.go b/remote/gchat/remote.go index d8113008..f255a310 100644 --- a/remote/gchat/remote.go +++ b/remote/gchat/remote.go @@ -50,7 +50,7 @@ func (c *Client) Name() string { } // Read messages from Google Chat. -func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.Rule, bot *models.Bot) { +func (c *Client) Read(inputMsgs chan<- models.Message, _ map[string]models.Rule, _ *models.Bot) { ctx := context.Background() // init client @@ -79,7 +79,7 @@ func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.R } // Send messages to Google Chat. -func (c *Client) Send(message models.Message, bot *models.Bot) { +func (c *Client) Send(message models.Message, _ *models.Bot) { ctx := context.Background() service, err := chat.NewService( @@ -110,6 +110,6 @@ func (c *Client) Send(message models.Message, bot *models.Bot) { } // Reaction implementation to satisfy remote interface. -func (c *Client) Reaction(message models.Message, rule models.Rule, bot *models.Bot) { +func (c *Client) Reaction(_ models.Message, _ models.Rule, _ *models.Bot) { // Not implemented for Google Chat } diff --git a/remote/scheduler/remote.go b/remote/scheduler/remote.go index 3cf5bb6c..a6b0f6d3 100644 --- a/remote/scheduler/remote.go +++ b/remote/scheduler/remote.go @@ -27,7 +27,7 @@ func (c *Client) Name() string { } // Reaction implementation to satisfy remote interface. -func (c *Client) Reaction(message models.Message, rule models.Rule, bot *models.Bot) { +func (c *Client) Reaction(_ models.Message, _ models.Rule, _ *models.Bot) { // not implemented for Scheduler } @@ -123,7 +123,7 @@ func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.R } // Send implementation to satisfy remote interface. -func (c *Client) Send(message models.Message, bot *models.Bot) { +func (c *Client) Send(_ models.Message, _ *models.Bot) { // not implemented for Scheduler } diff --git a/remote/slack/helper.go b/remote/slack/helper.go index d3f1cd10..79dc1caf 100644 --- a/remote/slack/helper.go +++ b/remote/slack/helper.go @@ -28,7 +28,7 @@ Slack helper functions (anything that uses the 'slack-go/slack' package) */ // getEventsAPIHealthHandler creates and returns the handler for health checks on the Slack Events API reader. -func getEventsAPIHealthHandler(bot *models.Bot) func(w http.ResponseWriter, r *http.Request) { +func getEventsAPIHealthHandler(_ *models.Bot) func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { log.Error().Msgf("received invalid method: %s", r.Method) @@ -219,7 +219,6 @@ func getEventsAPIEventHandler(api *slack.Client, signingSecret string, inputMsgs // process regular Callback events if eventsAPIEvent.Type == slackevents.CallbackEvent { - //nolint:contextcheck // TODO: create and pass context? handleCallBack(api, eventsAPIEvent.InnerEvent, bot, inputMsgs, w) } } diff --git a/remote/slack/remote.go b/remote/slack/remote.go index 3a08b914..fd731d54 100644 --- a/remote/slack/remote.go +++ b/remote/slack/remote.go @@ -51,7 +51,7 @@ func (l *slackLogger) Output(_ int, s string) error { } // Reaction implementation to satisfy remote interface. -func (c *Client) Reaction(message models.Message, rule models.Rule, bot *models.Bot) { +func (c *Client) Reaction(message models.Message, rule models.Rule, _ *models.Bot) { if rule.RemoveReaction != "" { // Init api client api := c.new() @@ -83,7 +83,7 @@ func (c *Client) Reaction(message models.Message, rule models.Rule, bot *models. // Read implementation to satisfy remote interface // Utilizes the Slack API client to read messages from Slack. -func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.Rule, bot *models.Bot) { +func (c *Client) Read(inputMsgs chan<- models.Message, _ map[string]models.Rule, bot *models.Bot) { // init api client api := c.new() @@ -129,7 +129,7 @@ func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.R } // Send implementation to satisfy remote interface. -func (c *Client) Send(message models.Message, bot *models.Bot) { +func (c *Client) Send(message models.Message, _ *models.Bot) { log.Debug().Msgf("sending message %#q", message.ID) api := c.new() diff --git a/remote/telegram/remote.go b/remote/telegram/remote.go index 7995c5a7..c79e29bc 100644 --- a/remote/telegram/remote.go +++ b/remote/telegram/remote.go @@ -46,12 +46,12 @@ func (c *Client) Name() string { } // Reaction implementation to satisfy remote interface. -func (c *Client) Reaction(message models.Message, rule models.Rule, bot *models.Bot) { +func (c *Client) Reaction(_ models.Message, _ models.Rule, _ *models.Bot) { // not implemented for Telegram } // Read implementation to satisfy remote interface. -func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.Rule, bot *models.Bot) { +func (c *Client) Read(inputMsgs chan<- models.Message, _ map[string]models.Rule, bot *models.Bot) { telegramAPI := c.new() u := tgbotapi.NewUpdate(0) u.Timeout = 60 @@ -132,7 +132,7 @@ func (c *Client) Read(inputMsgs chan<- models.Message, rules map[string]models.R } // Send implementation to satisfy remote interface. -func (c *Client) Send(message models.Message, bot *models.Bot) { +func (c *Client) Send(message models.Message, _ *models.Bot) { telegramAPI := c.new() chatID, err := strconv.ParseInt(message.ChannelID, 10, 64)