From 1957d21975ff71af16bc8295997dee520fff0110 Mon Sep 17 00:00:00 2001 From: sprak Date: Thu, 7 Mar 2024 22:12:31 -0500 Subject: [PATCH 1/3] Issue #9: Lint action is failing - Debug line to see if revive is found at all... --- .github/workflows/quality-and-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/quality-and-tests.yml b/.github/workflows/quality-and-tests.yml index 6eaf814..ee9fe06 100644 --- a/.github/workflows/quality-and-tests.yml +++ b/.github/workflows/quality-and-tests.yml @@ -21,6 +21,8 @@ jobs: run: go mod tidy - name: go mod vendor run: go mod vendor + - name: Where is revive + run: which revive - name: Lint the code run: make lint - name: Vet the code From 4e310352c585d72003af9ec59a380027a616f0cf Mon Sep 17 00:00:00 2001 From: sprak Date: Thu, 7 Mar 2024 22:14:56 -0500 Subject: [PATCH 2/3] Issue #9: Lint action is failing - Use latest revive install command. --- .github/workflows/quality-and-tests.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/quality-and-tests.yml b/.github/workflows/quality-and-tests.yml index ee9fe06..0277117 100644 --- a/.github/workflows/quality-and-tests.yml +++ b/.github/workflows/quality-and-tests.yml @@ -16,13 +16,11 @@ jobs: - name: Install gotestsum run: make install-gotestsum - name: Install revive - run: go get -u github.com/mgechev/revive + run: go install github.com/mgechev/revive@latest - name: go mod tidy run: go mod tidy - name: go mod vendor run: go mod vendor - - name: Where is revive - run: which revive - name: Lint the code run: make lint - name: Vet the code From 6372521c0c993fa86c4c7d09fb6d9a4df9714484 Mon Sep 17 00:00:00 2001 From: sprak Date: Thu, 7 Mar 2024 22:21:53 -0500 Subject: [PATCH 3/3] Issue #9: Lint action is failing - Fix lint errors. - Adjust lint command in Makefile. No longer needs the return status reversed. --- Makefile | 2 +- slack/response_test.go | 12 ++++++------ statuspageio/response_test.go | 12 ++++++------ whatsup/client.go | 6 ++++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 21cf8d6..94bb79e 100755 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ analyze: lint vet test ## Run lint, vet, and test .PHONY: lint lint: ## Lint the code - @! revive -config .revive.toml ./... | grep -v vendor + @ revive -config .revive.toml ./... | grep -v vendor .PHONY: test test: unit-test ## Run the test suite(s). diff --git a/slack/response_test.go b/slack/response_test.go index a8ff080..9964c5f 100644 --- a/slack/response_test.go +++ b/slack/response_test.go @@ -57,12 +57,12 @@ func TestUnit_ReadStatus(t *testing.T) { }, }, }, - setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient { + setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient { c := clientmock.NewMockBaseClient(ctrl) c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusOK, []byte(sampleActiveResp), expectedErr) return c }, - validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) { + validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) { require.Equal(t, expectedResp, actualResp) require.NoError(t, actualErr) }, @@ -70,12 +70,12 @@ func TestUnit_ReadStatus(t *testing.T) { "exceptional path- unable to make client request": { expectedResp: Response{}, expectedErr: glitch.NewDataError(nil, "test-err-code", "test-err"), - setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient { + setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient { c := clientmock.NewMockBaseClient(ctrl) c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusInternalServerError, nil, expectedErr) return c }, - validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) { + validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) { require.Equal(t, expectedResp, actualResp) require.Error(t, actualErr) require.Equal(t, status.ErrorUnableToMakeClientRequest, actualErr.Code()) @@ -83,12 +83,12 @@ func TestUnit_ReadStatus(t *testing.T) { }, "exceptional path- unable to parse response": { expectedResp: Response{}, - setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient { + setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient { c := clientmock.NewMockBaseClient(ctrl) c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusOK, []byte(`{bad: ^JSON`), expectedErr) return c }, - validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) { + validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) { require.Equal(t, expectedResp, actualResp) require.Error(t, actualErr) require.Equal(t, status.ErrorUnableToParseClientResponse, actualErr.Code()) diff --git a/statuspageio/response_test.go b/statuspageio/response_test.go index 8c715bd..0b92242 100644 --- a/statuspageio/response_test.go +++ b/statuspageio/response_test.go @@ -41,12 +41,12 @@ func TestUnit_ReadStatus(t *testing.T) { UpdatedAt: sampleOKTime, }, }, - setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient { + setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient { c := clientmock.NewMockBaseClient(ctrl) c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusOK, []byte(sampleOKResp), expectedErr) return c }, - validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) { + validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) { require.Equal(t, expectedResp, actualResp) require.NoError(t, actualErr) }, @@ -54,12 +54,12 @@ func TestUnit_ReadStatus(t *testing.T) { "exceptional path- unable to make client request": { expectedResp: Response{}, expectedErr: glitch.NewDataError(nil, "test-err-code", "test-err"), - setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient { + setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient { c := clientmock.NewMockBaseClient(ctrl) c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusInternalServerError, nil, expectedErr) return c }, - validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) { + validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) { require.Equal(t, expectedResp, actualResp) require.Error(t, actualErr) require.Equal(t, status.ErrorUnableToMakeClientRequest, actualErr.Code()) @@ -67,12 +67,12 @@ func TestUnit_ReadStatus(t *testing.T) { }, "exceptional path- unable to parse response": { expectedResp: Response{}, - setupBaseClient: func(t *testing.T, expectedErr glitch.DataError) client.BaseClient { + setupBaseClient: func(_ *testing.T, expectedErr glitch.DataError) client.BaseClient { c := clientmock.NewMockBaseClient(ctrl) c.EXPECT().MakeRequest(gomock.Any(), http.MethodGet, "test-slug", nil, gomock.Any(), nil).Return(http.StatusOK, []byte(`{bad: ^JSON`), expectedErr) return c }, - validate: func(t *testing.T, expectedResp, actualResp status.Details, expectedErr, actualErr glitch.DataError) { + validate: func(t *testing.T, expectedResp, actualResp status.Details, _, actualErr glitch.DataError) { require.Equal(t, expectedResp, actualResp) require.Error(t, actualErr) require.Equal(t, status.ErrorUnableToParseClientResponse, actualErr.Code()) diff --git a/whatsup/client.go b/whatsup/client.go index 173d64d..449c53f 100644 --- a/whatsup/client.go +++ b/whatsup/client.go @@ -32,7 +32,8 @@ func NewStatusPageClient() StatusPageClient { // StatuspageIoService handles fetching statuspage.io style status pages func (spc *statusPageClient) StatuspageIoService(serviceName, pageURL string) (status.Details, glitch.DataError) { u, err := url.Parse(pageURL) - sf := func(serviceName string, useTLS bool) (url.URL, error) { + // No use for service name or use TLS flag here. + sf := func(_ string, _ bool) (url.URL, error) { return *u, err } c := client.NewBaseClient(sf, serviceName, true, 10*time.Second, nil) @@ -43,7 +44,8 @@ func (spc *statusPageClient) StatuspageIoService(serviceName, pageURL string) (s func (spc *statusPageClient) Slack() (status.Details, glitch.DataError) { sn := slack.ServiceType u, err := url.Parse("https://status.slack.com/api/v2.0.0/current") - sf := func(serviceName string, useTLS bool) (url.URL, error) { + // No use for service name or use TLS flag here. + sf := func(_ string, _ bool) (url.URL, error) { return *u, err } c := client.NewBaseClient(sf, sn, true, 10*time.Second, nil)