Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby committed Dec 28, 2024
1 parent 97de5d3 commit 8e213e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -872,11 +872,11 @@ func (app *App) Config() Config {
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
// prepare the server for the start
app.startupProcess()

if app.newCtxFunc != nil {
return app.customRequestHandler
} else {
return app.defaultRequestHandler
}

Check warning on line 878 in app.go

View check run for this annotation

Codecov / codecov/patch

app.go#L877-L878

Added lines #L877 - L878 were not covered by tests
return app.defaultRequestHandler
}

// Stack returns the raw router stack.
Expand Down
4 changes: 1 addition & 3 deletions binder/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ func parseToStruct(aliasTag string, out any, data map[string][]string) error {
func parseToMap(ptr any, data map[string][]string) error {
elem := reflect.TypeOf(ptr).Elem()

//nolint:exhaustive // it's not necessary to check all types
switch elem.Kind() {
switch elem.Kind() { //nolint:exhaustive // it's not necessary to check all types
case reflect.Slice:
newMap, ok := ptr.(map[string][]string)
if !ok {
Expand All @@ -129,7 +128,6 @@ func parseToMap(ptr any, data map[string][]string) error {
newMap[k] = ""
continue
}

newMap[k] = v[len(v)-1]
}
}
Expand Down
18 changes: 9 additions & 9 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package fiber

import (
"bytes"
"errors"
"fmt"
"html"
"sort"
Expand Down Expand Up @@ -214,16 +215,14 @@ func (app *App) defaultRequestHandler(rctx *fasthttp.RequestCtx) {
// Acquire DefaultCtx from the pool
ctx, ok := app.AcquireCtx(rctx).(*DefaultCtx)
if !ok {
// Should not happen, but just in case:
panic("defaultRequestHandler: failed to type-assert *DefaultCtx")
panic(errors.New("requestHandler: failed to type-assert to *DefaultCtx"))

Check warning on line 218 in router.go

View check run for this annotation

Codecov / codecov/patch

router.go#L218

Added line #L218 was not covered by tests
}

defer app.ReleaseCtx(ctx)

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

Expand All @@ -237,24 +236,24 @@ func (app *App) defaultRequestHandler(rctx *fasthttp.RequestCtx) {
_, err := app.next(ctx)
if err != nil {
if catch := ctx.App().ErrorHandler(ctx, err); catch != nil {
_ = ctx.SendStatus(StatusInternalServerError)
_ = ctx.SendStatus(StatusInternalServerError) //nolint:errcheck // Always return nil
}
// TODO: Do we need to return here?
}
}

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

Check warning on line 249 in router.go

View check run for this annotation

Codecov / codecov/patch

router.go#L249

Added line #L249 was not covered by tests
}

defer app.ReleaseCtx(c)

// Check if the HTTP method is valid
if app.methodInt(c.Method()) == -1 {
_ = c.SendStatus(StatusNotImplemented)
_ = c.SendStatus(StatusNotImplemented) //nolint:errcheck // Always return nil
return
}

Expand All @@ -268,8 +267,9 @@ func (app *App) customRequestHandler(rctx *fasthttp.RequestCtx) {
_, err := app.nextCustom(c)
if err != nil {
if catch := c.App().ErrorHandler(c, err); catch != nil {
_ = c.SendStatus(StatusInternalServerError)
_ = c.SendStatus(StatusInternalServerError) //nolint:errcheck // Always return nil

Check warning on line 270 in router.go

View check run for this annotation

Codecov / codecov/patch

router.go#L270

Added line #L270 was not covered by tests
}
// TODO: Do we need to return here?
}
}

Expand Down

0 comments on commit 8e213e0

Please sign in to comment.