Skip to content

Commit 8d7015d

Browse files
authored
Merge branch 'main' into fix-3186
2 parents 022d3c7 + 2c7bdb9 commit 8d7015d

File tree

15 files changed

+30
-31
lines changed

15 files changed

+30
-31
lines changed

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
uses: golangci/golangci-lint-action@v6
3838
with:
3939
# NOTE: Keep this in sync with the version from .golangci.yml
40-
version: v1.61.0
40+
version: v1.62.0

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ markdown:
3535
## lint: 🚨 Run lint checks
3636
.PHONY: lint
3737
lint:
38-
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 run ./...
38+
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0 run ./...
3939

4040
## test: 🚦 Execute all tests
4141
.PHONY: test

client/hooks_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func Test_Parser_Request_Header(t *testing.T) {
254254

255255
err := parserRequestHeader(client, req)
256256
require.NoError(t, err)
257-
require.Equal(t, []byte(applicationJSON), req.RawRequest.Header.ContentType())
257+
require.Equal(t, []byte(applicationJSON), req.RawRequest.Header.ContentType()) //nolint:testifylint // test
258258
})
259259

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

298298
err := parserRequestHeader(client, req)
299299
require.NoError(t, err)
300-
require.True(t, strings.Contains(string(req.RawRequest.Header.MultipartFormBoundary()), "--FiberFormBoundary"))
301-
require.True(t, strings.Contains(string(req.RawRequest.Header.ContentType()), multipartFormData))
300+
require.Contains(t, string(req.RawRequest.Header.MultipartFormBoundary()), "--FiberFormBoundary")
301+
require.Contains(t, string(req.RawRequest.Header.ContentType()), multipartFormData)
302302
})
303303

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

437437
err := parserRequestBody(client, req)
438438
require.NoError(t, err)
439-
require.Equal(t, []byte("{\"name\":\"foo\"}"), req.RawRequest.Body())
439+
require.Equal(t, []byte("{\"name\":\"foo\"}"), req.RawRequest.Body()) //nolint:testifylint // test
440440
})
441441

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

490490
err := parserRequestBody(client, req)
491491
require.NoError(t, err)
492-
require.True(t, strings.Contains(string(req.RawRequest.Body()), "----FiberFormBoundary"))
493-
require.True(t, strings.Contains(string(req.RawRequest.Body()), "world"))
492+
require.Contains(t, string(req.RawRequest.Body()), "----FiberFormBoundary")
493+
require.Contains(t, string(req.RawRequest.Body()), "world")
494494
})
495495

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

503503
err := parserRequestBody(client, req)
504504
require.NoError(t, err)
505-
require.True(t, strings.Contains(string(req.RawRequest.Body()), "----FiberFormBoundary"))
506-
require.True(t, strings.Contains(string(req.RawRequest.Body()), "world"))
507-
require.True(t, strings.Contains(string(req.RawRequest.Body()), "bar"))
505+
require.Contains(t, string(req.RawRequest.Body()), "----FiberFormBoundary")
506+
require.Contains(t, string(req.RawRequest.Body()), "world")
507+
require.Contains(t, string(req.RawRequest.Body()), "bar")
508508
})
509509

510510
t.Run("raw body", func(t *testing.T) {

client/response_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ func Test_Response_Save(t *testing.T) {
375375

376376
data, err := io.ReadAll(file)
377377
require.NoError(t, err)
378-
require.Equal(t, "{\"status\":\"success\"}", string(data))
378+
require.JSONEq(t, "{\"status\":\"success\"}", string(data))
379379
})
380380

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

397397
err = resp.Save(buf)
398398
require.NoError(t, err)
399-
require.Equal(t, "{\"status\":\"success\"}", buf.String())
399+
require.JSONEq(t, "{\"status\":\"success\"}", buf.String())
400400
})
401401

402402
t.Run("error type", func(t *testing.T) {

ctx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,7 @@ func (*DefaultCtx) SaveFileToStorage(fileheader *multipart.FileHeader, path stri
14701470
if err != nil {
14711471
return fmt.Errorf("failed to open: %w", err)
14721472
}
1473+
defer file.Close() //nolint:errcheck // not needed
14731474

14741475
content, err := io.ReadAll(file)
14751476
if err != nil {

ctx_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ func Test_Ctx_AutoFormat_Struct(t *testing.T) {
11891189
c.Request().Header.Set(HeaderAccept, MIMEApplicationJSON)
11901190
err := c.AutoFormat(data)
11911191
require.NoError(t, err)
1192-
require.Equal(t,
1192+
require.JSONEq(t,
11931193
`{"Sender":"Carol","Recipients":["Alice","Bob"],"Urgency":3}`,
11941194
string(c.Response().Body()),
11951195
)
@@ -3549,7 +3549,7 @@ func Test_Ctx_JSON(t *testing.T) {
35493549
"Age": 20,
35503550
})
35513551
require.NoError(t, err)
3552-
require.Equal(t, `{"Age":20,"Name":"Grame"}`, string(c.Response().Body()))
3552+
require.JSONEq(t, `{"Age":20,"Name":"Grame"}`, string(c.Response().Body()))
35533553
require.Equal(t, "application/json", string(c.Response().Header.Peek("content-type")))
35543554

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

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

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

log/default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (l *defaultLogger) privateLogw(lv Level, format string, keysAndValues []any
9393
if i > 0 || format != "" {
9494
buf.WriteByte(' ')
9595
}
96-
buf.WriteString(keysAndValues[i].(string)) //nolint:forcetypeassert // Keys must be strings
96+
buf.WriteString(keysAndValues[i].(string)) //nolint:forcetypeassert,errcheck // Keys must be strings
9797
buf.WriteByte('=')
9898
buf.WriteString(utils.ToString(keysAndValues[i+1]))
9999
}

middleware/adaptor/adaptor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func handlerFunc(app *fiber.App, h ...fiber.Handler) http.HandlerFunc {
163163
}
164164
}
165165

166-
if _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil && err.(*net.AddrError).Err == "missing port in address" { //nolint:errorlint, forcetypeassert // overlinting
166+
if _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil && err.(*net.AddrError).Err == "missing port in address" { //nolint:errorlint,forcetypeassert,errcheck // overlinting
167167
r.RemoteAddr = net.JoinHostPort(r.RemoteAddr, "80")
168168
}
169169

middleware/cache/heap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (h indexedHeap) Swap(i, j int) {
4141
}
4242

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

4747
func (h *indexedHeap) Pop() any {

middleware/cache/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func newManager(storage fiber.Storage) *manager {
5050

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

5656
// release and reset *entry to sync.Pool

middleware/limiter/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func newManager(storage fiber.Storage) *manager {
4545

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

5151
// release and reset *entry to sync.Pool

middleware/logger/default_logger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func defaultLoggerInstance(c fiber.Ctx, data *Data, cfg Config) error {
3131
}
3232
buf.WriteString(
3333
fmt.Sprintf("%s |%s %3d %s| %13v | %15s |%s %-7s %s| %-"+data.ErrPaddingStr+"s %s\n",
34-
data.Timestamp.Load().(string), //nolint:forcetypeassert // Timestamp is always a string
34+
data.Timestamp.Load().(string), //nolint:forcetypeassert,errcheck // Timestamp is always a string
3535
statusColor(c.Response().StatusCode(), colors), c.Response().StatusCode(), colors.Reset,
3636
data.Stop.Sub(data.Start),
3737
c.IP(),
@@ -61,7 +61,7 @@ func defaultLoggerInstance(c fiber.Ctx, data *Data, cfg Config) error {
6161
}
6262

6363
// Timestamp
64-
buf.WriteString(data.Timestamp.Load().(string)) //nolint:forcetypeassert // Timestamp is always a string
64+
buf.WriteString(data.Timestamp.Load().(string)) //nolint:forcetypeassert,errcheck // Timestamp is always a string
6565
buf.WriteString(" | ")
6666

6767
// Status Code with 3 fixed width, right aligned

middleware/logger/logger_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ func Test_Logger_WithLatency(t *testing.T) {
305305
require.Equal(t, fiber.StatusOK, resp.StatusCode)
306306

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

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

356354
// Reset the buffer
357355
buff.Reset()

middleware/logger/tags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func createTagMap(cfg *Config) map[string]LogFunc {
200200
return output.WriteString(fmt.Sprintf("%13v", latency))
201201
},
202202
TagTime: func(output Buffer, _ fiber.Ctx, data *Data, _ string) (int, error) {
203-
return output.WriteString(data.Timestamp.Load().(string)) //nolint:forcetypeassert // We always store a string in here
203+
return output.WriteString(data.Timestamp.Load().(string)) //nolint:forcetypeassert,errcheck // We always store a string in here
204204
},
205205
}
206206
// merge with custom tags from user

router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (app *App) requestHandler(rctx *fasthttp.RequestCtx) {
234234
if app.newCtxFunc != nil {
235235
_, err = app.nextCustom(c)
236236
} else {
237-
_, err = app.next(c.(*DefaultCtx))
237+
_, err = app.next(c.(*DefaultCtx)) //nolint:errcheck // It is fine to ignore the error here
238238
}
239239
if err != nil {
240240
if catch := c.App().ErrorHandler(c, err); catch != nil {

0 commit comments

Comments
 (0)