Skip to content

Commit

Permalink
fix: upgrade golangci lint to 1.56.2
Browse files Browse the repository at this point in the history
  • Loading branch information
savsgio committed Mar 4, 2024
1 parent 075d858 commit d1ec043
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ jobs:
- uses: actions/checkout@v3
- uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2
version: v1.56.2
32 changes: 16 additions & 16 deletions atreugo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ func Test_New(t *testing.T) { //nolint:funlen,gocognit,gocyclo
err bool
}

jsonMarshalFunc := func(w io.Writer, body interface{}) error {
jsonMarshalFunc := func(_ io.Writer, _ interface{}) error {
return nil
}
notFoundView := func(ctx *RequestCtx) error {
notFoundView := func(_ *RequestCtx) error {
return nil
}
methodNotAllowedView := func(ctx *RequestCtx) error {
methodNotAllowedView := func(_ *RequestCtx) error {
return nil
}

panicErr := errors.New("error")
panicView := func(ctx *RequestCtx, err interface{}) {
ctx.Error(panicErr.Error(), fasthttp.StatusInternalServerError)
ctx.Error(fmt.Sprint(err), fasthttp.StatusInternalServerError)
}

tests := []struct {
Expand Down Expand Up @@ -210,10 +210,10 @@ func Test_New(t *testing.T) { //nolint:funlen,gocognit,gocyclo
func Test_newFasthttpServer(t *testing.T) { //nolint:funlen
cfg := Config{
Name: "test",
HeaderReceived: func(header *fasthttp.RequestHeader) fasthttp.RequestConfig {
HeaderReceived: func(_ *fasthttp.RequestHeader) fasthttp.RequestConfig {
return fasthttp.RequestConfig{}
},
ContinueHandler: func(header *fasthttp.RequestHeader) bool { return true },
ContinueHandler: func(_ *fasthttp.RequestHeader) bool { return true },
Concurrency: rand.Int(), // nolint:gosec
ReadBufferSize: rand.Int(), // nolint:gosec
WriteBufferSize: rand.Int(), // nolint:gosec
Expand Down Expand Up @@ -244,7 +244,7 @@ func Test_newFasthttpServer(t *testing.T) { //nolint:funlen
ConnState: func(net.Conn, fasthttp.ConnState) {},
Logger: testLog,
TLSConfig: &tls.Config{ServerName: "test", MinVersion: tls.VersionTLS13},
FormValueFunc: func(ctx *fasthttp.RequestCtx, key string) []byte { return nil },
FormValueFunc: func(_ *fasthttp.RequestCtx, _ string) []byte { return nil },
}

srv := newFasthttpServer(cfg)
Expand Down Expand Up @@ -576,15 +576,15 @@ func TestAtreugo_NewVirtualHost(t *testing.T) { //nolint:funlen
conflictHosts := []conflictArgs{
{
hostnames: []string{hostname},
wantErrMsg: fmt.Sprintf("a router is already registered for virtual host: %s", hostname),
wantErrMsg: "a router is already registered for virtual host: " + hostname,
},
{
hostnames: []string{},
wantErrMsg: "at least 1 hostname is required",
},
{
hostnames: []string{"localhost", "localhost"},
wantErrMsg: fmt.Sprintf("a router is already registered for virtual host: %s", hostname),
wantErrMsg: "a router is already registered for virtual host: " + hostname,
},
}

Expand Down Expand Up @@ -679,13 +679,13 @@ func TestAtreugo_ShutdownWithContext(t *testing.T) {
// Benchmarks.
func Benchmark_Handler(b *testing.B) {
s := New(testConfig)
s.GET("/plaintext", func(ctx *RequestCtx) error { return nil })
s.GET("/json", func(ctx *RequestCtx) error { return nil })
s.GET("/db", func(ctx *RequestCtx) error { return nil })
s.GET("/queries", func(ctx *RequestCtx) error { return nil })
s.GET("/cached-worlds", func(ctx *RequestCtx) error { return nil })
s.GET("/fortunes", func(ctx *RequestCtx) error { return nil })
s.GET("/updates", func(ctx *RequestCtx) error { return nil })
s.GET("/plaintext", func(_ *RequestCtx) error { return nil })
s.GET("/json", func(_ *RequestCtx) error { return nil })
s.GET("/db", func(_ *RequestCtx) error { return nil })
s.GET("/queries", func(_ *RequestCtx) error { return nil })
s.GET("/cached-worlds", func(_ *RequestCtx) error { return nil })
s.GET("/fortunes", func(_ *RequestCtx) error { return nil })
s.GET("/updates", func(_ *RequestCtx) error { return nil })

ctx := new(fasthttp.RequestCtx)
ctx.Request.Header.SetMethod("GET")
Expand Down
2 changes: 1 addition & 1 deletion listener_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestAtreugo_getListener(t *testing.T) { // nolint:funlen,gocognit
s := New(tt.args)

if tt.name == "UnixChmodError" {
s.cfg.chmodUnixSocketFunc = func(addr string) error {
s.cfg.chmodUnixSocketFunc = func(_ string) error {
return errors.New("chmod error")
}
}
Expand Down
8 changes: 3 additions & 5 deletions path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func newTestPath() *Path {
router: testRouter(),
method: fasthttp.MethodGet,
url: "/test",
view: func(ctx *RequestCtx) error { return nil },
view: func(_ *RequestCtx) error { return nil },
}
}

Expand Down Expand Up @@ -98,10 +98,8 @@ func TestPath_UseAfter(t *testing.T) {

func TestPath_UseFinal(t *testing.T) {
finalMiddlewareFns := []FinalMiddleware{
func(ctx *RequestCtx) {
},
func(ctx *RequestCtx) {
},
func(_ *RequestCtx) {},
func(_ *RequestCtx) {},
}

p := newTestPath()
Expand Down
4 changes: 2 additions & 2 deletions response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ func TestJSONResponse(t *testing.T) { //nolint:funlen
{
name: "CustomJSONMarshalFunc",
args: args{
body: make(chan int),
body: "my custom response",
statusCode: 200,
jsonMarshalFunc: func(w io.Writer, value interface{}) error {
_, err := w.Write([]byte("my custom response"))
_, err := w.Write([]byte(fmt.Sprint(value)))

return err // nolint:wrapcheck
},
Expand Down
39 changes: 20 additions & 19 deletions router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestRouter_newRouter(t *testing.T) {
}

func TestRouter_mutable(t *testing.T) {
handler := func(ctx *fasthttp.RequestCtx) {}
handler := func(_ *fasthttp.RequestCtx) {}

r := testRouter()
r.router.GET("/", handler)
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestRouter_buildMiddlewares(t *testing.T) {
middleware1 := func(ctx *RequestCtx) error { return ctx.Next() }
middleware2 := func(ctx *RequestCtx) error { return ctx.Next() }
middleware3 := func(ctx *RequestCtx) error { return ctx.Next() }
middleware4 := func(ctx *RequestCtx) {}
middleware4 := func(_ *RequestCtx) {}

middle := Middlewares{
Before: []Middleware{middleware1, middleware2},
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestRouter_handlerExecutionChain(t *testing.T) { //nolint:funlen

return ctx.Next()
})
s.UseFinal(func(ctx *RequestCtx) {
s.UseFinal(func(_ *RequestCtx) {
index++
callOrder["globalFinal"] = index
})
Expand All @@ -294,14 +294,14 @@ func TestRouter_handlerExecutionChain(t *testing.T) { //nolint:funlen

return ctx.Next()
}, skipMiddlewareGroup)
v1.UseFinal(func(ctx *RequestCtx) {
v1.UseFinal(func(_ *RequestCtx) {
index++
callOrder["groupFinal"] = index
})

v1.SkipMiddlewares(skipMiddlewareGlobal)

v1.Path(method, url, func(ctx *RequestCtx) error {
v1.Path(method, url, func(_ *RequestCtx) error {
viewCalled = true

return nil
Expand All @@ -315,7 +315,7 @@ func TestRouter_handlerExecutionChain(t *testing.T) { //nolint:funlen
callOrder["viewAfter"] = index

return ctx.Next()
}).UseFinal(func(ctx *RequestCtx) {
}).UseFinal(func(_ *RequestCtx) {
index++
callOrder["viewFinal"] = index
}).SkipMiddlewares(skipMiddlewareGroup)
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestRouter_handler(t *testing.T) { //nolint:funlen,maintidx
},
}
final := []FinalMiddleware{
func(ctx *RequestCtx) {
func(_ *RequestCtx) {
handlerCounter.finalMiddlewares++
},
}
Expand All @@ -446,7 +446,7 @@ func TestRouter_handler(t *testing.T) { //nolint:funlen,maintidx
},
},
Final: []FinalMiddleware{
func(ctx *RequestCtx) {
func(_ *RequestCtx) {
handlerCounter.finalViewMiddlewares++
},
},
Expand Down Expand Up @@ -511,7 +511,7 @@ func TestRouter_handler(t *testing.T) { //nolint:funlen,maintidx
{
name: "ViewError",
args: args{
viewFn: func(ctx *RequestCtx) error {
viewFn: func(_ *RequestCtx) error {
return err
},
before: before,
Expand Down Expand Up @@ -583,7 +583,7 @@ func TestRouter_handler(t *testing.T) { //nolint:funlen,maintidx
},
},
Final: []FinalMiddleware{
func(ctx *RequestCtx) {
func(_ *RequestCtx) {
handlerCounter.finalViewMiddlewares++
},
},
Expand Down Expand Up @@ -625,7 +625,7 @@ func TestRouter_handler(t *testing.T) { //nolint:funlen,maintidx
},
},
Final: []FinalMiddleware{
func(ctx *RequestCtx) {
func(_ *RequestCtx) {
handlerCounter.finalViewMiddlewares++
},
},
Expand Down Expand Up @@ -677,7 +677,7 @@ func TestRouter_handler(t *testing.T) { //nolint:funlen,maintidx
args: args{
viewFn: viewFn,
before: []Middleware{
func(ctx *RequestCtx) error {
func(_ *RequestCtx) error {
handlerCounter.beforeMiddlewares++

return nil
Expand Down Expand Up @@ -785,7 +785,7 @@ func TestRouter_handlePath(t *testing.T) {
router: r,
method: fasthttp.MethodGet,
url: "/test",
view: func(ctx *RequestCtx) error { return nil },
view: func(_ *RequestCtx) error { return nil },
middlewares: Middlewares{},
withTimeout: true,
timeout: 1 * time.Millisecond,
Expand Down Expand Up @@ -867,8 +867,8 @@ func TestRouter_NewGroupPath(t *testing.T) {
func TestRouter_ListPaths(t *testing.T) {
server := New(testConfig)

server.Path("GET", "/foo", func(ctx *RequestCtx) error { return nil })
server.Path("GET", "/bar", func(ctx *RequestCtx) error { return nil })
server.Path("GET", "/foo", func(_ *RequestCtx) error { return nil })
server.Path("GET", "/bar", func(_ *RequestCtx) error { return nil })

static := server.NewGroupPath("/static")
static.Static("/buzz", "./docs")
Expand Down Expand Up @@ -924,7 +924,7 @@ func TestRouter_SkipMiddlewares(t *testing.T) {

func TestRouter_Path_Shortcuts(t *testing.T) { //nolint:funlen
path := "/"
viewFn := func(ctx *RequestCtx) error { return nil }
viewFn := func(_ *RequestCtx) error { return nil }

r := testRouter()

Expand Down Expand Up @@ -1111,6 +1111,7 @@ func TestRouter_StaticCustom(t *testing.T) { //nolint:funlen
})

ctx := new(fasthttp.RequestCtx)

handler, _ := r.router.Lookup("GET", tt.want.routerPath, ctx)
if handler == nil {
t.Fatal("Static files is not configured")
Expand Down Expand Up @@ -1187,7 +1188,7 @@ func TestRouter_Path(t *testing.T) { //nolint:funlen
return nil
}

testNetHTTPHandler := func(w http.ResponseWriter, r *http.Request) {
testNetHTTPHandler := func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, "Test")
}
testMuxHandler := http.NewServeMux()
Expand Down Expand Up @@ -1337,7 +1338,7 @@ func TestRouter_Path(t *testing.T) { //nolint:funlen
func Benchmark_handler(b *testing.B) {
r := testRouter()

h := r.handler(func(ctx *RequestCtx) error { return nil }, Middlewares{})
h := r.handler(func(_ *RequestCtx) error { return nil }, Middlewares{})

ctx := new(fasthttp.RequestCtx)

Expand All @@ -1350,7 +1351,7 @@ func Benchmark_handler(b *testing.B) {

func Benchmark_RouterHandler(b *testing.B) {
r := testRouter()
r.GET("/", func(ctx *RequestCtx) error { return nil })
r.GET("/", func(_ *RequestCtx) error { return nil })

ctx := new(fasthttp.RequestCtx)
ctx.Request.Header.SetMethod("GET")
Expand Down
10 changes: 5 additions & 5 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Test_viewToHandler(t *testing.T) {
called := false
err := errors.New("error")

view := func(ctx *RequestCtx) error {
view := func(_ *RequestCtx) error {
called = true

return err
Expand Down Expand Up @@ -84,8 +84,8 @@ func Test_isEqual(t *testing.T) {
}

func Test_middlewaresInclude(t *testing.T) {
fnIncluded := func(ctx *RequestCtx) error { return nil }
fnNotIncluded := func(ctx *RequestCtx) error { return nil }
fnIncluded := func(_ *RequestCtx) error { return nil }
fnNotIncluded := func(_ *RequestCtx) error { return nil }
ms := []Middleware{fnIncluded}

if !middlewaresInclude(ms, fnIncluded) {
Expand All @@ -98,8 +98,8 @@ func Test_middlewaresInclude(t *testing.T) {
}

func Test_appendMiddlewares(t *testing.T) {
fn := func(ctx *RequestCtx) error { return nil }
fnSkip := func(ctx *RequestCtx) error { return nil }
fn := func(_ *RequestCtx) error { return nil }
fnSkip := func(_ *RequestCtx) error { return nil }

dst := []Middleware{}
src := []Middleware{fn, fnSkip}
Expand Down

0 comments on commit d1ec043

Please sign in to comment.