mirror of https://github.com/gofiber/fiber.git
Enable SA4023
parent
0a225b8f43
commit
bdb405eb5b
|
@ -97,11 +97,6 @@ linters-settings:
|
|||
# show-ignored: true # TODO: Enable this
|
||||
audit: true
|
||||
|
||||
staticcheck:
|
||||
checks:
|
||||
- all
|
||||
- '-SA4023' # disable the rule SA4023
|
||||
|
||||
govet:
|
||||
enable-all: true
|
||||
disable:
|
||||
|
|
3
Makefile
3
Makefile
|
@ -35,7 +35,8 @@ markdown:
|
|||
## lint: 🚨 Run lint checks
|
||||
.PHONY: lint
|
||||
lint:
|
||||
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.7 run ./...
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.7
|
||||
golangci-lint run ./...
|
||||
|
||||
## test: 🚦 Execute all tests
|
||||
.PHONY: test
|
||||
|
|
|
@ -4578,7 +4578,7 @@ func Test_Ctx_SendStreamWriter(t *testing.T) {
|
|||
c := app.AcquireCtx(&fasthttp.RequestCtx{})
|
||||
|
||||
err := c.SendStreamWriter(func(w *bufio.Writer) {
|
||||
w.WriteString("Don't crash please") //nolint:errcheck,revive // It is fine to ignore the error
|
||||
w.WriteString("Don't crash please") //nolint:errcheck // It is fine to ignore the error
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Don't crash please", string(c.Response().Body()))
|
||||
|
|
|
@ -51,16 +51,16 @@ func getTLSConfig(ln net.Listener) *tls.Config {
|
|||
}
|
||||
|
||||
// Copy value from pointer
|
||||
if val := reflect.Indirect(pointer); val.Type() != nil {
|
||||
if val := reflect.Indirect(pointer); val.IsValid() {
|
||||
// Get private field from value
|
||||
if field := val.FieldByName("config"); field.Type() != nil {
|
||||
if field := val.FieldByName("config"); field.IsValid() {
|
||||
// Copy value from pointer field (unsafe)
|
||||
newval := reflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())) //nolint:gosec // Probably the only way to extract the *tls.Config from a net.Listener. TODO: Verify there really is no easier way without using unsafe.
|
||||
if newval.Type() == nil {
|
||||
if !newval.IsValid() {
|
||||
return nil
|
||||
}
|
||||
// Get element from pointer
|
||||
if elem := newval.Elem(); elem.Type() != nil {
|
||||
if elem := newval.Elem(); elem.IsValid() {
|
||||
// Cast value to *tls.Config
|
||||
c, ok := elem.Interface().(*tls.Config)
|
||||
if !ok {
|
||||
|
|
|
@ -506,7 +506,10 @@ func Test_Proxy_Do_WithRealURL(t *testing.T) {
|
|||
return Do(c, "https://www.google.com")
|
||||
})
|
||||
|
||||
resp, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil))
|
||||
resp, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil), fiber.TestConfig{
|
||||
Timeout: 2 * time.Second,
|
||||
FailOnTimeout: true,
|
||||
})
|
||||
require.NoError(t, err1)
|
||||
require.Equal(t, fiber.StatusOK, resp.StatusCode)
|
||||
require.Equal(t, "/test", resp.Request.URL.String())
|
||||
|
@ -523,7 +526,10 @@ func Test_Proxy_Do_WithRedirect(t *testing.T) {
|
|||
return Do(c, "https://google.com")
|
||||
})
|
||||
|
||||
resp, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil))
|
||||
resp, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil), fiber.TestConfig{
|
||||
Timeout: 2 * time.Second,
|
||||
FailOnTimeout: true,
|
||||
})
|
||||
require.NoError(t, err1)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
@ -558,7 +564,10 @@ func Test_Proxy_DoRedirects_TooManyRedirects(t *testing.T) {
|
|||
return DoRedirects(c, "http://google.com", 0)
|
||||
})
|
||||
|
||||
resp, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil))
|
||||
resp, err1 := app.Test(httptest.NewRequest(fiber.MethodGet, "/test", nil), fiber.TestConfig{
|
||||
Timeout: 2 * time.Second,
|
||||
FailOnTimeout: true,
|
||||
})
|
||||
require.NoError(t, err1)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Reference in New Issue