Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: enable bodyclose lint (#8171)

Danny Xuf8e4a6c80113
diff --git a/.golangci.yaml b/.golangci.yaml
index bb913f3958..4a338f7942 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -16,6 +16,7 @@ linters:
- godot
- forbidigo
- mirror
+ - bodyclose
# golangci-lint run --exclude="Rollback,logger.Sync,pgInstance.Stop"
issues:
diff --git a/backend/plugin/app/feishu/feishu.go b/backend/plugin/app/feishu/feishu.go
index beb3f10072..c934db3c78 100644
--- a/backend/plugin/app/feishu/feishu.go
+++ b/backend/plugin/app/feishu/feishu.go
@@ -344,6 +344,7 @@ func (p *Provider) tokenRefresher(tokenCtx TokenCtx) tokenRefresher {
func (p *Provider) do(ctx context.Context, client *http.Client, method, url string, body []byte, tokenRefresher tokenRefresher) (code int, header http.Header, respBody string, err error) {
token := p.Token.Load().(string)
+ //nolint:bodyclose
return retry(ctx, client, &token, tokenRefresher, requester(ctx, client, method, url, &token, body))
}
diff --git a/backend/plugin/vcs/internal/oauth/oauth.go b/backend/plugin/vcs/internal/oauth/oauth.go
index 6923559d37..65e75d44fb 100644
--- a/backend/plugin/vcs/internal/oauth/oauth.go
+++ b/backend/plugin/vcs/internal/oauth/oauth.go
@@ -21,6 +21,7 @@ import (
type TokenRefresher func(ctx context.Context, client *http.Client, oldToken *string) error
func requester(ctx context.Context, client *http.Client, method, url string, token *string, body io.Reader) func() (*http.Response, error) {
+ //nolint:bodyclose
return requesterWithHeader(ctx, client, method, url, token, body, nil)
}
@@ -67,12 +68,14 @@ func Post(ctx context.Context, client *http.Client, url string, token *string, b
// additional header. It refreshes token and retries the request in the case of
// the token has expired.
func PostWithHeader(ctx context.Context, client *http.Client, url string, token *string, body io.Reader, tokenRefresher TokenRefresher, header map[string]string) (code int, _ http.Header, respBody string, err error) {
+ //nolint:bodyclose
return retry(ctx, client, token, tokenRefresher, requesterWithHeader(ctx, client, http.MethodPost, url, token, body, header))
}
// Get makes a HTTP GET request to the given URL using the token. It refreshes
// token and retries the request in the case of the token has expired.
func Get(ctx context.Context, client *http.Client, url string, token *string, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {
+ //nolint:bodyclose
return retry(ctx, client, token, tokenRefresher, requester(ctx, client, http.MethodGet, url, token, nil))
}
@@ -80,24 +83,28 @@ func Get(ctx context.Context, client *http.Client, url string, token *string, to
// additional header. It refreshes token and retries the request in the case of
// the token has expired.
func GetWithHeader(ctx context.Context, client *http.Client, url string, token *string, tokenRefresher TokenRefresher, header map[string]string) (code int, _ http.Header, respBody string, err error) {
+ //nolint:bodyclose
return retry(ctx, client, token, tokenRefresher, requesterWithHeader(ctx, client, http.MethodGet, url, token, nil, header))
}
// Put makes a HTTP PUT request to the given URL using the token. It refreshes
// token and retries the request in the case of the token has expired.
func Put(ctx context.Context, client *http.Client, url string, token *string, body io.Reader, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {
+ //nolint:bodyclose
return retry(ctx, client, token, tokenRefresher, requester(ctx, client, http.MethodPut, url, token, body))
}
// Patch makes a HTTP PATCH request to the given URL using the token. It
// refreshes token and retries the request in the case of the token has expired.
func Patch(ctx context.Context, client *http.Client, url string, token *string, body io.Reader, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {
+ //nolint:bodyclose
return retry(ctx, client, token, tokenRefresher, requester(ctx, client, http.MethodPatch, url, token, body))
}
// Delete makes a HTTP DELETE request to the given URL using the token. It refreshes
// token and retries the request in the case of the token has expired.
func Delete(ctx context.Context, client *http.Client, url string, token *string, tokenRefresher TokenRefresher) (code int, header http.Header, respBody string, err error) {
+ //nolint:bodyclose
return retry(ctx, client, token, tokenRefresher, requester(ctx, client, http.MethodDelete, url, token, nil))
}