From f62dfef76e9d05700c606dac8c1d4084f5d67618 Mon Sep 17 00:00:00 2001 From: Sergey Aksenov Date: Wed, 11 Oct 2023 18:37:24 +0200 Subject: [PATCH 1/2] chore: bump golangci-lint version --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index dd2452e4e..1bd1b8fd5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -119,7 +119,7 @@ jobs: uses: golangci/golangci-lint-action@v3 timeout-minutes: 20 with: - version: v1.51.2 + version: v1.54.2 working-directory: ${{ matrix.dir }} args: --timeout=20m From ae3fb0490fff61eba53f218f0cd9f979e2b1e2cc Mon Sep 17 00:00:00 2001 From: Sergey Aksenov Date: Wed, 11 Oct 2023 19:48:38 +0200 Subject: [PATCH 2/2] chore: fix warnings introduced by new golangci-lint version --- assertion_validation.go | 6 +----- e2e/context_test.go | 2 +- e2e/mocks_test.go | 2 +- formatter.go | 20 ++++++++++---------- mocks_test.go | 12 ++++++------ nocopy_test.go | 2 +- object.go | 2 +- reporter_test.go | 4 ++-- websocket_test.go | 2 +- 9 files changed, 24 insertions(+), 28 deletions(-) diff --git a/assertion_validation.go b/assertion_validation.go index 0880e663d..521502e4f 100644 --- a/assertion_validation.go +++ b/assertion_validation.go @@ -18,11 +18,7 @@ func validateAssertion(failure *AssertionFailure) error { } } - if err := validateType(failure); err != nil { - return err - } - - return nil + return validateType(failure) } func validateType(failure *AssertionFailure) error { diff --git a/e2e/context_test.go b/e2e/context_test.go index 26af3ea1f..e887e8216 100644 --- a/e2e/context_test.go +++ b/e2e/context_test.go @@ -109,7 +109,7 @@ func newErrorSuppressor( } } -func (h *errorSuppressor) Success(ctx *httpexpect.AssertionContext) { +func (h *errorSuppressor) Success(*httpexpect.AssertionContext) { } func (h *errorSuppressor) Failure( diff --git a/e2e/mocks_test.go b/e2e/mocks_test.go index dd8cbf9ae..af757aab3 100644 --- a/e2e/mocks_test.go +++ b/e2e/mocks_test.go @@ -5,6 +5,6 @@ type mockReporter struct { } // Errorf implements Reporter.Errorf. -func (r *mockReporter) Errorf(message string, args ...interface{}) { +func (r *mockReporter) Errorf(_ string, _ ...interface{}) { r.failed = true } diff --git a/formatter.go b/formatter.go index 02985f31c..6a5f970bc 100644 --- a/formatter.go +++ b/formatter.go @@ -354,7 +354,7 @@ func (f *DefaultFormatter) fillGeneral( } func (f *DefaultFormatter) fillErrors( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, _ *AssertionContext, failure *AssertionFailure, ) { data.Errors = []string{} @@ -367,7 +367,7 @@ func (f *DefaultFormatter) fillErrors( } func (f *DefaultFormatter) fillActual( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, _ *AssertionContext, failure *AssertionFailure, ) { switch failure.Type { //nolint case AssertUsage, AssertOperation: @@ -384,7 +384,7 @@ func (f *DefaultFormatter) fillActual( } func (f *DefaultFormatter) fillExpected( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, _ *AssertionContext, failure *AssertionFailure, ) { switch failure.Type { case AssertUsage, AssertOperation, @@ -478,7 +478,7 @@ func (f *DefaultFormatter) fillExpected( } func (f *DefaultFormatter) fillIsNegation( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, _ *AssertionContext, failure *AssertionFailure, ) { switch failure.Type { case AssertUsage, AssertOperation, @@ -518,7 +518,7 @@ func (f *DefaultFormatter) fillIsNegation( } func (f *DefaultFormatter) fillIsComparison( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, _ *AssertionContext, failure *AssertionFailure, ) { switch failure.Type { //nolint case AssertLt, AssertLe, AssertGt, AssertGe: @@ -527,21 +527,21 @@ func (f *DefaultFormatter) fillIsComparison( } func (f *DefaultFormatter) fillReference( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, _ *AssertionContext, failure *AssertionFailure, ) { data.HaveReference = true data.Reference = f.formatValue(failure.Reference.Value) } func (f *DefaultFormatter) fillDelta( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, _ *AssertionContext, failure *AssertionFailure, ) { data.HaveDelta = true data.Delta = f.formatValue(failure.Delta.Value) } func (f *DefaultFormatter) fillRequest( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, ctx *AssertionContext, _ *AssertionFailure, ) { if !f.DisableRequests && ctx.Request != nil && ctx.Request.httpReq != nil { dump, err := httputil.DumpRequest(ctx.Request.httpReq, false) @@ -555,7 +555,7 @@ func (f *DefaultFormatter) fillRequest( } func (f *DefaultFormatter) fillResponse( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, ctx *AssertionContext, _ *AssertionFailure, ) { if !f.DisableResponses && ctx.Response != nil && ctx.Response.httpResp != nil { dump, err := httputil.DumpResponse(ctx.Response.httpResp, false) @@ -572,7 +572,7 @@ func (f *DefaultFormatter) fillResponse( } func (f *DefaultFormatter) fillStacktrace( - data *FormatData, ctx *AssertionContext, failure *AssertionFailure, + data *FormatData, _ *AssertionContext, failure *AssertionFailure, ) { data.Stacktrace = []string{} diff --git a/mocks_test.go b/mocks_test.go index c2a3e6c75..c16308a10 100644 --- a/mocks_test.go +++ b/mocks_test.go @@ -78,7 +78,7 @@ func (mf *mockFormatter) FormatSuccess(ctx *AssertionContext) string { } func (mf *mockFormatter) FormatFailure( - ctx *AssertionContext, failure *AssertionFailure, + ctx *AssertionContext, _ *AssertionFailure, ) string { mf.formattedFailure++ return ctx.TestName @@ -126,11 +126,11 @@ func (mp *mockWebsocketPrinter) Request(*http.Request) { func (mp *mockWebsocketPrinter) Response(*http.Response, time.Duration) { } -func (mp *mockWebsocketPrinter) WebsocketWrite(typ int, content []byte, closeCode int) { +func (mp *mockWebsocketPrinter) WebsocketWrite(int, []byte, int) { mp.isWrittenTo = true } -func (mp *mockWebsocketPrinter) WebsocketRead(typ int, content []byte, closeCode int) { +func (mp *mockWebsocketPrinter) WebsocketRead(int, []byte, int) { mp.isReadFrom = true } @@ -154,11 +154,11 @@ func (mc *mockWebsocketConn) Close() error { return mc.closeError } -func (mc *mockWebsocketConn) SetReadDeadline(t time.Time) error { +func (mc *mockWebsocketConn) SetReadDeadline(time.Time) error { return mc.readDlError } -func (mc *mockWebsocketConn) SetWriteDeadline(t time.Time) error { +func (mc *mockWebsocketConn) SetWriteDeadline(time.Time) error { return mc.writeDlError } @@ -166,7 +166,7 @@ func (mc *mockWebsocketConn) ReadMessage() (messageType int, p []byte, err error return mc.msgType, []byte{}, mc.readMsgErr } -func (mc *mockWebsocketConn) WriteMessage(messageType int, data []byte) error { +func (mc *mockWebsocketConn) WriteMessage(int, []byte) error { return mc.writeMsgErr } diff --git a/nocopy_test.go b/nocopy_test.go index 8ab573f86..c9f113bba 100644 --- a/nocopy_test.go +++ b/nocopy_test.go @@ -4,7 +4,7 @@ import ( "testing" ) -func TestNoCopy(t *testing.T) { +func TestNoCopy(*testing.T) { var n noCopy n.Lock() diff --git a/object.go b/object.go index ec827538d..f93700f41 100644 --- a/object.go +++ b/object.go @@ -1201,7 +1201,7 @@ func (o *Object) sortedKV() []kv { } func containsKey( - opChain *chain, obj map[string]interface{}, key string, + _ *chain, obj map[string]interface{}, key string, ) bool { for k := range obj { if k == key { diff --git a/reporter_test.go b/reporter_test.go index 3e0dd6ccf..4ef394eda 100644 --- a/reporter_test.go +++ b/reporter_test.go @@ -11,7 +11,7 @@ type mockT struct { fatalfInvoked bool } -func (m *mockT) Fatalf(format string, args ...interface{}) { +func (m *mockT) Fatalf(string, ...interface{}) { m.fatalfInvoked = true } @@ -19,7 +19,7 @@ type mockAssertT struct { errorfInvoked bool } -func (m *mockAssertT) Errorf(format string, args ...interface{}) { +func (m *mockAssertT) Errorf(string, ...interface{}) { m.errorfInvoked = true } diff --git a/websocket_test.go b/websocket_test.go index 2ebe9b44f..b15cd94af 100644 --- a/websocket_test.go +++ b/websocket_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" ) -func noWsPreSteps(ws *Websocket) {} +func noWsPreSteps(*Websocket) {} func TestWebsocket_FailedChain(t *testing.T) { reporter := newMockReporter(t)