diff --git a/.golangci.yml b/.golangci.yml index 4238b6c..ba171f1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,6 +15,11 @@ linters: - scopelint - structcheck - varcheck + - intrange + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 linters-settings: lll: diff --git a/configuration/configuration.go b/configuration/configuration.go index c48072e..38916ce 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -56,6 +56,7 @@ func ReadConfiguration(fsys fs.FS, filename string) (*Configuration, error) { config := Configuration{} + //nolint:musttag err = json.Unmarshal(filedata, &config) if err != nil { return nil, fmt.Errorf("%w", err) diff --git a/configuration/configuration_test.go b/configuration/configuration_test.go index ff7f628..45bcdae 100644 --- a/configuration/configuration_test.go +++ b/configuration/configuration_test.go @@ -172,8 +172,6 @@ func TestReadConfiguration_Errors(t *testing.T) { } for testCaseName, testCase := range testCases { - testCaseName, testCase := testCaseName, testCase - t.Run(testCaseName, func(tt *testing.T) { tt.Parallel() diff --git a/go.mod b/go.mod index a206e6a..71f12c8 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/blueprintue/discord-bot go 1.22 require ( - github.com/bwmarrin/discordgo v0.27.1 + github.com/bwmarrin/discordgo v0.28.1 github.com/crazy-max/gohealthchecks v0.4.1 github.com/ilya1st/rotatewriter v0.0.0-20171126183947-3df0c1a3ed6d github.com/rs/zerolog v1.32.0 diff --git a/go.sum b/go.sum index 037c274..99bc0d0 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/bwmarrin/discordgo v0.27.1 h1:ib9AIc/dom1E/fSIulrBwnez0CToJE113ZGt4HoliGY= -github.com/bwmarrin/discordgo v0.27.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= +github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4= +github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/crazy-max/gohealthchecks v0.4.1 h1:gbjZzF/GxwDyP78u37B2/c2iQfq8BEjAHS3eBLM6FcQ= github.com/crazy-max/gohealthchecks v0.4.1/go.mod h1:gkT8QSdEXZJahyswdTGDbd+q20fWm0DmWW7TWBNtgJg= diff --git a/hack/lint.Dockerfile b/hack/lint.Dockerfile index c52e10e..b7f2e3d 100644 --- a/hack/lint.Dockerfile +++ b/hack/lint.Dockerfile @@ -5,9 +5,9 @@ ENV GOFLAGS="-buildvcs=false" RUN apk add --no-cache gcc linux-headers musl-dev WORKDIR /src -FROM golangci/golangci-lint:latest-alpine AS golangci-lint +FROM golangci/golangci-lint:v1.57.2-alpine AS golangci-lint FROM base AS lint RUN --mount=type=bind,target=. \ - --mount=type=cache,target=/root/.cache \ - --mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \ + --mount=type=cache,target=/root/.cache \ + --mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \ golangci-lint run ./... \ No newline at end of file diff --git a/healthchecks/healthchecks_test.go b/healthchecks/healthchecks_test.go index 82cf9fc..7f45a85 100644 --- a/healthchecks/healthchecks_test.go +++ b/healthchecks/healthchecks_test.go @@ -89,8 +89,6 @@ func TestNewHealthchecksManager_ErrorHasValidConfigurationInFile(t *testing.T) { } for testCaseName, testCase := range testCases { - testCaseName, testCase := testCaseName, testCase - t.Run(testCaseName, func(tt *testing.T) { var bufferLogs bytes.Buffer log.Logger = zerolog.New(&bufferLogs).Level(zerolog.TraceLevel).With().Logger() diff --git a/welcome/welcome_handler_test.go b/welcome/welcome_handler_test.go index 37aad0e..5109948 100644 --- a/welcome/welcome_handler_test.go +++ b/welcome/welcome_handler_test.go @@ -87,7 +87,7 @@ func TestHandlers_OnMessageReactionAdd(t *testing.T) { []requestTest{ {method: "GET", host: "discord.com", uri: "/api/v9/channels/channel-123/messages?limit=100"}, {method: "POST", host: "discord.com", uri: "/api/v9/channels/channel-123/messages", - body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null}`}, + body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null,"sticker_ids":null}`}, {method: "PUT", host: "discord.com", uri: "/api/v9/channels/channel-123/messages/123/reactions/my-emoji-1:emoji-123/@me"}, {method: "PUT", host: "discord.com", uri: "/api/v9/guilds/guild-123/members/user-id-456/roles/role-123"}, }, @@ -277,7 +277,7 @@ func TestHandlers_OnMessageReactionAdd_Errors(t *testing.T) { []requestTest{ {method: "GET", host: "discord.com", uri: "/api/v9/channels/channel-123/messages?limit=100"}, {method: "POST", host: "discord.com", uri: "/api/v9/channels/channel-123/messages", - body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null}`}, + body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null,"sticker_ids":null}`}, {method: "PUT", host: "discord.com", uri: "/api/v9/channels/channel-123/messages/123/reactions/my-emoji-1:emoji-123/@me"}, {method: "PUT", host: "discord.com", uri: "/api/v9/guilds/guild-123/members/user-id-456/roles/role-123"}, }, @@ -377,7 +377,7 @@ func TestHandlers_OnMessageReactionRemove(t *testing.T) { []requestTest{ {method: "GET", host: "discord.com", uri: "/api/v9/channels/channel-123/messages?limit=100"}, {method: "POST", host: "discord.com", uri: "/api/v9/channels/channel-123/messages", - body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null}`}, + body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null,"sticker_ids":null}`}, {method: "PUT", host: "discord.com", uri: "/api/v9/channels/channel-123/messages/123/reactions/my-emoji-1:emoji-123/@me"}, {method: "DELETE", host: "discord.com", uri: "/api/v9/guilds/guild-123/members/user-id-789/roles/role-123"}, }, @@ -566,7 +566,7 @@ func TestHandlers_OnMessageReactionRemove_Errors(t *testing.T) { []requestTest{ {method: "GET", host: "discord.com", uri: "/api/v9/channels/channel-123/messages?limit=100"}, {method: "POST", host: "discord.com", uri: "/api/v9/channels/channel-123/messages", - body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null}`}, + body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null,"sticker_ids":null}`}, {method: "PUT", host: "discord.com", uri: "/api/v9/channels/channel-123/messages/123/reactions/my-emoji-1:emoji-123/@me"}, {method: "DELETE", host: "discord.com", uri: "/api/v9/guilds/guild-123/members/user-id-789/roles/role-123"}, }, diff --git a/welcome/welcome_run_test.go b/welcome/welcome_run_test.go index f33da41..50bf3b1 100644 --- a/welcome/welcome_run_test.go +++ b/welcome/welcome_run_test.go @@ -89,7 +89,7 @@ func TestRun(t *testing.T) { []requestTest{ {method: "GET", host: "discord.com", uri: "/api/v9/channels/channel-123/messages?limit=100"}, {method: "POST", host: "discord.com", uri: "/api/v9/channels/channel-123/messages", - body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null}`}, + body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null,"sticker_ids":null}`}, {method: "PUT", host: "discord.com", uri: "/api/v9/channels/channel-123/messages/123/reactions/my-emoji-1:emoji-123/@me"}, }, ) @@ -327,7 +327,7 @@ func TestRun_Errors(t *testing.T) { []requestTest{ {method: "GET", host: "discord.com", uri: "/api/v9/channels/channel-123/messages?limit=100"}, {method: "POST", host: "discord.com", uri: "/api/v9/channels/channel-123/messages", - body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null}`}, + body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null,"sticker_ids":null}`}, }, ) @@ -389,7 +389,7 @@ func TestRun_Errors(t *testing.T) { []requestTest{ {method: "GET", host: "discord.com", uri: "/api/v9/channels/channel-123/messages?limit=100"}, {method: "POST", host: "discord.com", uri: "/api/v9/channels/channel-123/messages", - body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null}`}, + body: `{"embeds":[{"type":"rich","title":"my title 1"}],"tts":false,"components":null,"sticker_ids":null}`}, {method: "PUT", host: "discord.com", uri: "/api/v9/channels/channel-123/messages/123/reactions/my-emoji-1:emoji-123/@me"}, }, )