Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump golangci-lint to v1.62.0 #3196

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
# NOTE: Keep this in sync with the version from .golangci.yml
version: v1.61.0
version: v1.62.0
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ markdown:
## lint: 🚨 Run lint checks
.PHONY: lint
lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 run ./...
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0 run ./...

## test: 🚦 Execute all tests
.PHONY: test
Expand Down
18 changes: 9 additions & 9 deletions client/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func Test_Parser_Request_Header(t *testing.T) {

err := parserRequestHeader(client, req)
require.NoError(t, err)
require.Equal(t, []byte(applicationJSON), req.RawRequest.Header.ContentType())
require.Equal(t, []byte(applicationJSON), req.RawRequest.Header.ContentType()) //nolint:testifylint // test
})

t.Run("auto set xml header", func(t *testing.T) {
Expand Down Expand Up @@ -297,8 +297,8 @@ func Test_Parser_Request_Header(t *testing.T) {

err := parserRequestHeader(client, req)
require.NoError(t, err)
require.True(t, strings.Contains(string(req.RawRequest.Header.MultipartFormBoundary()), "--FiberFormBoundary"))
require.True(t, strings.Contains(string(req.RawRequest.Header.ContentType()), multipartFormData))
require.Contains(t, string(req.RawRequest.Header.MultipartFormBoundary()), "--FiberFormBoundary")
require.Contains(t, string(req.RawRequest.Header.ContentType()), multipartFormData)
})

t.Run("ua should have default value", func(t *testing.T) {
Expand Down Expand Up @@ -436,7 +436,7 @@ func Test_Parser_Request_Body(t *testing.T) {

err := parserRequestBody(client, req)
require.NoError(t, err)
require.Equal(t, []byte("{\"name\":\"foo\"}"), req.RawRequest.Body())
require.Equal(t, []byte("{\"name\":\"foo\"}"), req.RawRequest.Body()) //nolint:testifylint // test
gaby marked this conversation as resolved.
Show resolved Hide resolved
})

t.Run("xml body", func(t *testing.T) {
Expand Down Expand Up @@ -489,8 +489,8 @@ func Test_Parser_Request_Body(t *testing.T) {

err := parserRequestBody(client, req)
require.NoError(t, err)
require.True(t, strings.Contains(string(req.RawRequest.Body()), "----FiberFormBoundary"))
require.True(t, strings.Contains(string(req.RawRequest.Body()), "world"))
require.Contains(t, string(req.RawRequest.Body()), "----FiberFormBoundary")
require.Contains(t, string(req.RawRequest.Body()), "world")
})

t.Run("file and form data", func(t *testing.T) {
Expand All @@ -502,9 +502,9 @@ func Test_Parser_Request_Body(t *testing.T) {

err := parserRequestBody(client, req)
require.NoError(t, err)
require.True(t, strings.Contains(string(req.RawRequest.Body()), "----FiberFormBoundary"))
require.True(t, strings.Contains(string(req.RawRequest.Body()), "world"))
require.True(t, strings.Contains(string(req.RawRequest.Body()), "bar"))
require.Contains(t, string(req.RawRequest.Body()), "----FiberFormBoundary")
require.Contains(t, string(req.RawRequest.Body()), "world")
require.Contains(t, string(req.RawRequest.Body()), "bar")
})

t.Run("raw body", func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions client/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func Test_Response_Save(t *testing.T) {

data, err := io.ReadAll(file)
require.NoError(t, err)
require.Equal(t, "{\"status\":\"success\"}", string(data))
require.JSONEq(t, "{\"status\":\"success\"}", string(data))
})

t.Run("io.Writer", func(t *testing.T) {
Expand All @@ -396,7 +396,7 @@ func Test_Response_Save(t *testing.T) {

err = resp.Save(buf)
require.NoError(t, err)
require.Equal(t, "{\"status\":\"success\"}", buf.String())
require.JSONEq(t, "{\"status\":\"success\"}", buf.String())
})

t.Run("error type", func(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions ctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ func Test_Ctx_AutoFormat_Struct(t *testing.T) {
c.Request().Header.Set(HeaderAccept, MIMEApplicationJSON)
err := c.AutoFormat(data)
require.NoError(t, err)
require.Equal(t,
require.JSONEq(t,
`{"Sender":"Carol","Recipients":["Alice","Bob"],"Urgency":3}`,
string(c.Response().Body()),
)
Expand Down Expand Up @@ -3549,7 +3549,7 @@ func Test_Ctx_JSON(t *testing.T) {
"Age": 20,
})
require.NoError(t, err)
require.Equal(t, `{"Age":20,"Name":"Grame"}`, string(c.Response().Body()))
require.JSONEq(t, `{"Age":20,"Name":"Grame"}`, string(c.Response().Body()))
require.Equal(t, "application/json", string(c.Response().Header.Peek("content-type")))

// Test with ctype
Expand All @@ -3558,7 +3558,7 @@ func Test_Ctx_JSON(t *testing.T) {
"Age": 20,
}, "application/problem+json")
require.NoError(t, err)
require.Equal(t, `{"Age":20,"Name":"Grame"}`, string(c.Response().Body()))
require.JSONEq(t, `{"Age":20,"Name":"Grame"}`, string(c.Response().Body()))
require.Equal(t, "application/problem+json", string(c.Response().Header.Peek("content-type")))

testEmpty := func(v any, r string) {
Expand Down Expand Up @@ -3612,7 +3612,7 @@ func Benchmark_Ctx_JSON(b *testing.B) {
err = c.JSON(data)
}
require.NoError(b, err)
require.Equal(b, `{"Name":"Grame","Age":20}`, string(c.Response().Body()))
require.JSONEq(b, `{"Name":"Grame","Age":20}`, string(c.Response().Body()))
}

// go test -run=^$ -bench=Benchmark_Ctx_JSON_Ctype -benchmem -count=4
Expand All @@ -3635,7 +3635,7 @@ func Benchmark_Ctx_JSON_Ctype(b *testing.B) {
err = c.JSON(data, "application/problem+json")
}
require.NoError(b, err)
require.Equal(b, `{"Name":"Grame","Age":20}`, string(c.Response().Body()))
require.JSONEq(b, `{"Name":"Grame","Age":20}`, string(c.Response().Body()))
require.Equal(b, "application/problem+json", string(c.Response().Header.Peek("content-type")))
}

Expand Down
2 changes: 1 addition & 1 deletion log/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (l *defaultLogger) privateLogw(lv Level, format string, keysAndValues []any
if i > 0 || format != "" {
buf.WriteByte(' ')
}
buf.WriteString(keysAndValues[i].(string)) //nolint:forcetypeassert // Keys must be strings
buf.WriteString(keysAndValues[i].(string)) //nolint:forcetypeassert,errcheck // Keys must be strings
gaby marked this conversation as resolved.
Show resolved Hide resolved
buf.WriteByte('=')
buf.WriteString(utils.ToString(keysAndValues[i+1]))
}
Expand Down
2 changes: 1 addition & 1 deletion middleware/adaptor/adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func handlerFunc(app *fiber.App, h ...fiber.Handler) http.HandlerFunc {
}
}

if _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil && err.(*net.AddrError).Err == "missing port in address" { //nolint:errorlint, forcetypeassert // overlinting
if _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil && err.(*net.AddrError).Err == "missing port in address" { //nolint:errorlint,forcetypeassert,errcheck // overlinting
gaby marked this conversation as resolved.
Show resolved Hide resolved
r.RemoteAddr = net.JoinHostPort(r.RemoteAddr, "80")
}

Expand Down
2 changes: 1 addition & 1 deletion middleware/cache/heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}

func (h *indexedHeap) Push(x any) {
h.pushInternal(x.(heapEntry)) //nolint:forcetypeassert // Forced type assertion required to implement the heap.Interface interface
h.pushInternal(x.(heapEntry)) //nolint:forcetypeassert,errcheck // Forced type assertion required to implement the heap.Interface interface

Check warning on line 44 in middleware/cache/heap.go

View check run for this annotation

Codecov / codecov/patch

middleware/cache/heap.go#L44

Added line #L44 was not covered by tests
gaby marked this conversation as resolved.
Show resolved Hide resolved
}

func (h *indexedHeap) Pop() any {
Expand Down
2 changes: 1 addition & 1 deletion middleware/cache/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func newManager(storage fiber.Storage) *manager {

// acquire returns an *entry from the sync.Pool
func (m *manager) acquire() *item {
return m.pool.Get().(*item) //nolint:forcetypeassert // We store nothing else in the pool
return m.pool.Get().(*item) //nolint:forcetypeassert,errcheck // We store nothing else in the pool
}

// release and reset *entry to sync.Pool
Expand Down
2 changes: 1 addition & 1 deletion middleware/limiter/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newManager(storage fiber.Storage) *manager {

// acquire returns an *entry from the sync.Pool
func (m *manager) acquire() *item {
return m.pool.Get().(*item) //nolint:forcetypeassert // We store nothing else in the pool
return m.pool.Get().(*item) //nolint:forcetypeassert,errcheck // We store nothing else in the pool
gaby marked this conversation as resolved.
Show resolved Hide resolved
}

// release and reset *entry to sync.Pool
Expand Down
4 changes: 2 additions & 2 deletions middleware/logger/default_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func defaultLoggerInstance(c fiber.Ctx, data *Data, cfg Config) error {
}
buf.WriteString(
fmt.Sprintf("%s |%s %3d %s| %13v | %15s |%s %-7s %s| %-"+data.ErrPaddingStr+"s %s\n",
data.Timestamp.Load().(string), //nolint:forcetypeassert // Timestamp is always a string
data.Timestamp.Load().(string), //nolint:forcetypeassert,errcheck // Timestamp is always a string
gaby marked this conversation as resolved.
Show resolved Hide resolved
statusColor(c.Response().StatusCode(), colors), c.Response().StatusCode(), colors.Reset,
data.Stop.Sub(data.Start),
c.IP(),
Expand Down Expand Up @@ -61,7 +61,7 @@ func defaultLoggerInstance(c fiber.Ctx, data *Data, cfg Config) error {
}

// Timestamp
buf.WriteString(data.Timestamp.Load().(string)) //nolint:forcetypeassert // Timestamp is always a string
buf.WriteString(data.Timestamp.Load().(string)) //nolint:forcetypeassert,errcheck // Timestamp is always a string
gaby marked this conversation as resolved.
Show resolved Hide resolved
buf.WriteString(" | ")

// Status Code with 3 fixed width, right aligned
Expand Down
6 changes: 2 additions & 4 deletions middleware/logger/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ func Test_Logger_WithLatency(t *testing.T) {
require.Equal(t, fiber.StatusOK, resp.StatusCode)

// Assert that the log output contains the expected latency value in the current time unit
require.True(t, bytes.HasSuffix(buff.Bytes(), []byte(tu.unit)),
fmt.Sprintf("Expected latency to be in %s, got %s", tu.unit, buff.String()))
require.True(t, bytes.HasSuffix(buff.Bytes(), []byte(tu.unit)), "Expected latency to be in %s, got %s", tu.unit, buff.String())

// Reset the buffer
buff.Reset()
Expand Down Expand Up @@ -350,8 +349,7 @@ func Test_Logger_WithLatency_DefaultFormat(t *testing.T) {
// parse out the latency value from the log output
latency := bytes.Split(buff.Bytes(), []byte(" | "))[2]
// Assert that the latency value is in the current time unit
require.True(t, bytes.HasSuffix(latency, []byte(tu.unit)),
fmt.Sprintf("Expected latency to be in %s, got %s", tu.unit, latency))
require.True(t, bytes.HasSuffix(latency, []byte(tu.unit)), "Expected latency to be in %s, got %s", tu.unit, latency)

// Reset the buffer
buff.Reset()
Expand Down
2 changes: 1 addition & 1 deletion middleware/logger/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func createTagMap(cfg *Config) map[string]LogFunc {
return output.WriteString(fmt.Sprintf("%13v", latency))
},
TagTime: func(output Buffer, _ fiber.Ctx, data *Data, _ string) (int, error) {
return output.WriteString(data.Timestamp.Load().(string)) //nolint:forcetypeassert // We always store a string in here
return output.WriteString(data.Timestamp.Load().(string)) //nolint:forcetypeassert,errcheck // We always store a string in here
gaby marked this conversation as resolved.
Show resolved Hide resolved
},
}
// merge with custom tags from user
Expand Down
2 changes: 1 addition & 1 deletion router.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (app *App) requestHandler(rctx *fasthttp.RequestCtx) {
if app.newCtxFunc != nil {
_, err = app.nextCustom(c)
} else {
_, err = app.next(c.(*DefaultCtx))
_, err = app.next(c.(*DefaultCtx)) //nolint:errcheck // It is fine to ignore the error here
gaby marked this conversation as resolved.
Show resolved Hide resolved
}
if err != nil {
if catch := c.App().ErrorHandler(c, err); catch != nil {
Expand Down
Loading