Skip to content

Commit 8e213e0

Browse files
committed
Fix lint issues
1 parent 97de5d3 commit 8e213e0

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,11 +872,11 @@ func (app *App) Config() Config {
872872
func (app *App) Handler() fasthttp.RequestHandler { //revive:disable-line:confusing-naming // Having both a Handler() (uppercase) and a handler() (lowercase) is fine. TODO: Use nolint:revive directive instead. See https://github.com/golangci/golangci-lint/issues/3476
873873
// prepare the server for the start
874874
app.startupProcess()
875+
875876
if app.newCtxFunc != nil {
876877
return app.customRequestHandler
877-
} else {
878-
return app.defaultRequestHandler
879878
}
879+
return app.defaultRequestHandler
880880
}
881881

882882
// Stack returns the raw router stack.

binder/mapping.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ func parseToStruct(aliasTag string, out any, data map[string][]string) error {
107107
func parseToMap(ptr any, data map[string][]string) error {
108108
elem := reflect.TypeOf(ptr).Elem()
109109

110-
//nolint:exhaustive // it's not necessary to check all types
111-
switch elem.Kind() {
110+
switch elem.Kind() { //nolint:exhaustive // it's not necessary to check all types
112111
case reflect.Slice:
113112
newMap, ok := ptr.(map[string][]string)
114113
if !ok {
@@ -129,7 +128,6 @@ func parseToMap(ptr any, data map[string][]string) error {
129128
newMap[k] = ""
130129
continue
131130
}
132-
133131
newMap[k] = v[len(v)-1]
134132
}
135133
}

router.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package fiber
66

77
import (
88
"bytes"
9+
"errors"
910
"fmt"
1011
"html"
1112
"sort"
@@ -214,16 +215,14 @@ func (app *App) defaultRequestHandler(rctx *fasthttp.RequestCtx) {
214215
// Acquire DefaultCtx from the pool
215216
ctx, ok := app.AcquireCtx(rctx).(*DefaultCtx)
216217
if !ok {
217-
// Should not happen, but just in case:
218-
panic("defaultRequestHandler: failed to type-assert *DefaultCtx")
218+
panic(errors.New("requestHandler: failed to type-assert to *DefaultCtx"))
219219
}
220220

221221
defer app.ReleaseCtx(ctx)
222222

223223
// Check if the HTTP method is valid
224-
// (e.g., methodInt returns -1 if it's not found in app.config.RequestMethods)
225224
if ctx.methodINT == -1 {
226-
_ = ctx.SendStatus(StatusNotImplemented)
225+
_ = ctx.SendStatus(StatusNotImplemented) //nolint:errcheck // Always return nil
227226
return
228227
}
229228

@@ -237,24 +236,24 @@ func (app *App) defaultRequestHandler(rctx *fasthttp.RequestCtx) {
237236
_, err := app.next(ctx)
238237
if err != nil {
239238
if catch := ctx.App().ErrorHandler(ctx, err); catch != nil {
240-
_ = ctx.SendStatus(StatusInternalServerError)
239+
_ = ctx.SendStatus(StatusInternalServerError) //nolint:errcheck // Always return nil
241240
}
241+
// TODO: Do we need to return here?
242242
}
243243
}
244244

245245
func (app *App) customRequestHandler(rctx *fasthttp.RequestCtx) {
246246
// Acquire CustomCtx from the pool
247247
c, ok := app.AcquireCtx(rctx).(CustomCtx)
248248
if !ok {
249-
// Should not happen, but just in case:
250-
panic("customRequestHandler: failed to type-assert CustomCtx")
249+
panic(errors.New("requestHandler: failed to type-assert to CustomCtx"))
251250
}
252251

253252
defer app.ReleaseCtx(c)
254253

255254
// Check if the HTTP method is valid
256255
if app.methodInt(c.Method()) == -1 {
257-
_ = c.SendStatus(StatusNotImplemented)
256+
_ = c.SendStatus(StatusNotImplemented) //nolint:errcheck // Always return nil
258257
return
259258
}
260259

@@ -268,8 +267,9 @@ func (app *App) customRequestHandler(rctx *fasthttp.RequestCtx) {
268267
_, err := app.nextCustom(c)
269268
if err != nil {
270269
if catch := c.App().ErrorHandler(c, err); catch != nil {
271-
_ = c.SendStatus(StatusInternalServerError)
270+
_ = c.SendStatus(StatusInternalServerError) //nolint:errcheck // Always return nil
272271
}
272+
// TODO: Do we need to return here?
273273
}
274274
}
275275

0 commit comments

Comments
 (0)