From df12beb9417ecaa0ed6488890e143927e67e240d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rancoud?= Date: Sat, 27 Apr 2024 02:33:51 +0200 Subject: [PATCH] fix golangci-lint --- .golangci.yml | 5 +++++ configuration/configuration.go | 1 + configuration/configuration_test.go | 2 -- hack/lint.Dockerfile | 6 +++--- healthchecks/healthchecks_test.go | 2 -- welcome/welcome_handler_test.go | 8 ++++---- welcome/welcome_run_test.go | 6 +++--- 7 files changed, 16 insertions(+), 14 deletions(-) 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/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"}, }, )