diff --git a/.golangci.yml b/.golangci.yml index 9ba704817d..8b64eff852 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -118,7 +118,7 @@ linters: - revive - paralleltest - gocognit - - errcheck + # ENDTODO run: diff --git a/admin/commands/summary.go b/admin/commands/summary.go index 270d7b7892..7216a65df5 100644 --- a/admin/commands/summary.go +++ b/admin/commands/summary.go @@ -85,7 +85,7 @@ func addFile(zipW *zip.Writer, name string, fileName string) { logrus.Debugf("%s", err) r = io.NopCloser(bytes.NewReader([]byte(err.Error() + "\n"))) } - defer r.Close() //nolint:gosec + defer r.Close() //nolint:gosec,errcheck modTime := time.Now() if fi, _ := os.Stat(fileName); fi != nil { @@ -219,7 +219,7 @@ func addVMAgentTargets(ctx context.Context, zipW *zip.Writer, agentsInfo []*agen addData(zipW, "client/vmagent-targets.html", now, bytes.NewReader([]byte(err.Error()))) return } - defer res.Body.Close() //nolint:gosec + defer res.Body.Close() //nolint:gosec,errcheck html, err = io.ReadAll(res.Body) if err != nil { logrus.Debugf("%s", err) @@ -241,7 +241,7 @@ func getURL(ctx context.Context, url string) ([]byte, error) { if err != nil { return nil, errors.WithStack(err) } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck if resp.StatusCode != http.StatusOK { return nil, errors.Errorf("status code: %d", resp.StatusCode) diff --git a/admin/pkg/client/tarball/tarball.go b/admin/pkg/client/tarball/tarball.go index f9651f8bc3..45cd697eb0 100644 --- a/admin/pkg/client/tarball/tarball.go +++ b/admin/pkg/client/tarball/tarball.go @@ -148,7 +148,7 @@ func (b *Base) checksumTarball(ctx context.Context, link string, path string) er return err } - defer res.Body.Close() //nolint:gosec + defer res.Body.Close() //nolint:gosec,errcheck if res.StatusCode != http.StatusOK { return fmt.Errorf("%w: cannot download tarball's sha256sum (http %d)", ErrHTTPStatusNotOk, res.StatusCode) } diff --git a/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go b/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go index 4545595db6..f489af40a8 100644 --- a/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go +++ b/agent/agents/postgres/pgstatmonitor/pgstatmonitor.go @@ -366,7 +366,7 @@ func getPGSM20Settings(q *reform.Querier) (settings, error) { if err != nil { return nil, err } - defer rows.Close() + defer rows.Close() //nolint:errcheck result := make(settings) for rows.Next() { diff --git a/agent/agents/supervisor/ports_registry_test.go b/agent/agents/supervisor/ports_registry_test.go index 4528a35793..2fd56331bd 100644 --- a/agent/agents/supervisor/ports_registry_test.go +++ b/agent/agents/supervisor/ports_registry_test.go @@ -27,7 +27,7 @@ func TestRegistry(t *testing.T) { r := newPortsRegistry(65000, 65002, []uint16{65000}) l1, err := net.Listen("tcp", "127.0.0.1:65001") require.NoError(t, err) - defer l1.Close() //nolint:gosec + defer l1.Close() //nolint:gosec,errcheck p, err := r.Reserve() assert.NoError(t, err) @@ -46,8 +46,8 @@ func TestRegistry(t *testing.T) { err = r.Release(65002) assert.Equal(t, errPortBusy, err) - l1.Close() - l2.Close() + l1.Close() //nolint:errcheck + l2.Close() //nolint:errcheck p, err = r.Reserve() assert.NoError(t, err) diff --git a/agent/connectionchecker/connection_checker.go b/agent/connectionchecker/connection_checker.go index c59ac148e8..b3c78cc058 100644 --- a/agent/connectionchecker/connection_checker.go +++ b/agent/connectionchecker/connection_checker.go @@ -271,7 +271,7 @@ func (cc *ConnectionChecker) checkExternalConnection(ctx context.Context, uri st res.Error = err.Error() return &res } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck if resp.StatusCode != http.StatusOK { res.Error = fmt.Sprintf("Unexpected HTTP status code: %d. Expected: 200", resp.StatusCode) diff --git a/api-tests/server/auth_test.go b/api-tests/server/auth_test.go index 99158daac5..f8a798a6cb 100644 --- a/api-tests/server/auth_test.go +++ b/api-tests/server/auth_test.go @@ -62,7 +62,7 @@ func TestAuth(t *testing.T) { req, _ := http.NewRequestWithContext(pmmapitests.Context, http.MethodGet, uri.String(), nil) resp, err := http.DefaultClient.Do(req) require.NoError(t, err) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := httputil.DumpResponse(resp, true) require.NoError(t, err) @@ -119,7 +119,7 @@ func TestSetup(t *testing.T) { req.Header.Set("X-Test-Must-Setup", "1") resp, b := doRequest(t, client, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, 200, resp.StatusCode, "response:\n%s", b) assert.True(t, strings.HasPrefix(string(b), ``), string(b)) @@ -153,7 +153,7 @@ func TestSetup(t *testing.T) { req.Header.Set("X-Test-Must-Setup", "1") resp, b := doRequest(t, client, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, code, resp.StatusCode, "response:\n%s", b) if code == 303 { @@ -179,7 +179,7 @@ func TestSetup(t *testing.T) { req.Header.Set("X-Test-Must-Setup", "1") resp, b := doRequest(t, client, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, 200, resp.StatusCode, "response:\n%s", b) assert.Equal(t, "{}", string(b), "response:\n%s", b) @@ -214,7 +214,7 @@ func TestSwagger(t *testing.T) { require.NoError(t, err) resp, _ := doRequest(t, http.DefaultClient, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.NoError(t, err) assert.Equal(t, 200, resp.StatusCode) @@ -231,7 +231,7 @@ func TestSwagger(t *testing.T) { require.NoError(t, err) resp, _ := doRequest(t, http.DefaultClient, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.NoError(t, err) assert.Equal(t, 200, resp.StatusCode) @@ -318,7 +318,7 @@ func TestPermissions(t *testing.T) { resp, err := http.DefaultClient.Do(req) require.NoError(t, err) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, user.statusCode, resp.StatusCode) }) @@ -340,7 +340,7 @@ func TestPermissions(t *testing.T) { resp, err := http.DefaultClient.Do(req) require.NoError(t, err) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, user.statusCode, resp.StatusCode) }) @@ -360,7 +360,7 @@ func TestPermissions(t *testing.T) { resp, err := http.DefaultClient.Do(req) require.NoError(t, err) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, user.statusCode, resp.StatusCode) }) @@ -374,7 +374,7 @@ func doRequest(tb testing.TB, client *http.Client, req *http.Request) (*http.Res resp, err := client.Do(req) require.NoError(tb, err) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) require.NoError(tb, err) @@ -400,7 +400,7 @@ func deleteUser(t *testing.T, userID int) { require.NoError(t, err) resp, b := doRequest(t, http.DefaultClient, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.Equalf(t, http.StatusOK, resp.StatusCode, "failed to delete user, status code: %d, response: %s", resp.StatusCode, b) } @@ -426,7 +426,7 @@ func createUser(t *testing.T, login string) int { req.Header.Set("Content-Type", "application/json; charset=utf-8") resp, b := doRequest(t, http.DefaultClient, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.Equalf(t, http.StatusOK, resp.StatusCode, "failed to create user, status code: %d, response: %s", resp.StatusCode, b) var m map[string]interface{} @@ -453,7 +453,7 @@ func setRole(t *testing.T, userID int, role string) { req.Header.Set("Content-Type", "application/json; charset=utf-8") resp, b := doRequest(t, http.DefaultClient, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.Equalf(t, http.StatusOK, resp.StatusCode, "failed to set role for user, response: %s", b) } @@ -469,7 +469,7 @@ func deleteAPIKey(t *testing.T, apiKeyID int) { require.NoError(t, err) resp, b := doRequest(t, http.DefaultClient, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.Equalf(t, http.StatusOK, resp.StatusCode, "failed to delete API Key, status code: %d, response: %s", resp.StatusCode, b) } @@ -493,7 +493,7 @@ func createAPIKeyWithRole(t *testing.T, name, role string) (int, string) { req.Header.Set("Content-Type", "application/json; charset=utf-8") resp, b := doRequest(t, http.DefaultClient, req) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.Equalf(t, http.StatusOK, resp.StatusCode, "failed to create API key, status code: %d, response: %s", resp.StatusCode, b) @@ -509,7 +509,7 @@ func createAPIKeyWithRole(t *testing.T, name, role string) (int, string) { req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey)) resp1, b := doRequest(t, http.DefaultClient, req) - defer resp1.Body.Close() //nolint:gosec + defer resp1.Body.Close() //nolint:gosec,errcheck require.Equalf(t, http.StatusOK, resp1.StatusCode, "failed to get API key, status code: %d, response: %s", resp1.StatusCode, b) diff --git a/api-tests/server/readyz_test.go b/api-tests/server/readyz_test.go index 25a05f13ad..066f401b82 100644 --- a/api-tests/server/readyz_test.go +++ b/api-tests/server/readyz_test.go @@ -52,7 +52,7 @@ func TestReadyz(t *testing.T) { req, _ := http.NewRequestWithContext(pmmapitests.Context, http.MethodGet, uri.String(), nil) resp, err := http.DefaultClient.Do(req) require.NoError(t, err) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) require.NoError(t, err) diff --git a/api-tests/server/version_test.go b/api-tests/server/version_test.go index 3ac20024b2..46dbbf9d95 100644 --- a/api-tests/server/version_test.go +++ b/api-tests/server/version_test.go @@ -50,7 +50,7 @@ func TestVersion(t *testing.T) { req, _ := http.NewRequestWithContext(pmmapitests.Context, http.MethodGet, uri.String(), nil) resp, err := http.DefaultClient.Do(req) require.NoError(t, err) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) require.NoError(t, err) diff --git a/managed/models/job_helpers_test.go b/managed/models/job_helpers_test.go index c554b04e7a..7b179faba7 100644 --- a/managed/models/job_helpers_test.go +++ b/managed/models/job_helpers_test.go @@ -73,7 +73,7 @@ func TestJobs(t *testing.T) { t.Run("find", func(t *testing.T) { findTX, err := db.Begin() require.NoError(t, err) - defer findTX.Rollback() + defer findTX.Rollback() //nolint:errcheck const jobsCount = 3 jobs := make([]*models.Job, 0, jobsCount) diff --git a/managed/models/percona_sso_model_helpers.go b/managed/models/percona_sso_model_helpers.go index 55cda53440..5d4063a7e2 100644 --- a/managed/models/percona_sso_model_helpers.go +++ b/managed/models/percona_sso_model_helpers.go @@ -87,7 +87,7 @@ func (s *PerconaSSODetails) refreshAndGetAccessToken(ctx context.Context, q *ref if err != nil { return nil, err } - defer res.Body.Close() //nolint:gosec + defer res.Body.Close() //nolint:gosec,errcheck bodyBytes, err := io.ReadAll(res.Body) if err != nil { diff --git a/managed/services/alertmanager/alertmanager.go b/managed/services/alertmanager/alertmanager.go index 8a52c24a7a..a49a5c2d65 100644 --- a/managed/services/alertmanager/alertmanager.go +++ b/managed/services/alertmanager/alertmanager.go @@ -221,7 +221,7 @@ func (svc *Service) reload(ctx context.Context) error { if err != nil { return errors.WithStack(err) } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) svc.l.Debugf("Alertmanager reload: %s", b) @@ -859,7 +859,7 @@ func (svc *Service) IsReady(ctx context.Context) error { if err != nil { return errors.WithStack(err) } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) svc.l.Debugf("Alertmanager ready: %s", b) diff --git a/managed/services/dbaas/kubernetes/client/client.go b/managed/services/dbaas/kubernetes/client/client.go index 832023e00b..f29787d7df 100644 --- a/managed/services/dbaas/kubernetes/client/client.go +++ b/managed/services/dbaas/kubernetes/client/client.go @@ -230,7 +230,7 @@ func (c *Client) setup() error { } // Set PATH variable to make aws-iam-authenticator executable path := fmt.Sprintf("%s:%s", os.Getenv("PATH"), dbaasToolPath) - os.Setenv("PATH", path) + os.Setenv("PATH", path) //nolint:errcheck c.namespace = namespace return c.initOperatorClients() } @@ -567,7 +567,7 @@ func tabbedString(f func(io.Writer) error) (string, error) { return "", err } - out.Flush() + out.Flush() //nolint:errcheck str := buf.String() return str, nil } diff --git a/managed/services/dbaas/kubernetes/client/database/database.go b/managed/services/dbaas/kubernetes/client/database/database.go index b332f0f1e9..3b659927ab 100644 --- a/managed/services/dbaas/kubernetes/client/database/database.go +++ b/managed/services/dbaas/kubernetes/client/database/database.go @@ -50,7 +50,7 @@ func NewForConfig(c *rest.Config) (*DatabaseClusterClient, error) { config.UserAgent = rest.DefaultKubernetesUserAgent() addToScheme.Do(func() { - dbaasv1.SchemeBuilder.AddToScheme(scheme.Scheme) + dbaasv1.SchemeBuilder.AddToScheme(scheme.Scheme) //nolint:errcheck metav1.AddToGroupVersion(scheme.Scheme, dbaasv1.GroupVersion) }) diff --git a/managed/services/grafana/auth_server_test.go b/managed/services/grafana/auth_server_test.go index 77d341a36b..6a3994538d 100644 --- a/managed/services/grafana/auth_server_test.go +++ b/managed/services/grafana/auth_server_test.go @@ -80,7 +80,7 @@ func TestAuthServerMustSetup(t *testing.T) { assert.True(t, s.mustSetup(rw, req, logrus.WithField("test", t.Name()))) resp := rw.Result() - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, 401, resp.StatusCode) assert.Equal(t, "1", resp.Header.Get("X-Must-Setup")) assert.Equal(t, "", resp.Header.Get("Location")) @@ -97,7 +97,7 @@ func TestAuthServerMustSetup(t *testing.T) { assert.True(t, s.mustSetup(rw, req, logrus.WithField("test", t.Name()))) resp := rw.Result() - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, 303, resp.StatusCode) assert.Equal(t, "", resp.Header.Get("X-Must-Setup")) assert.Equal(t, "/setup", resp.Header.Get("Location")) @@ -123,7 +123,7 @@ func TestAuthServerMustSetup(t *testing.T) { assert.False(t, s.mustSetup(rw, req, logrus.WithField("test", t.Name()))) resp := rw.Result() - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, 200, resp.StatusCode) assert.Equal(t, "", resp.Header.Get("X-Must-Setup")) assert.Equal(t, "", resp.Header.Get("Location")) @@ -148,7 +148,7 @@ func TestAuthServerMustSetup(t *testing.T) { assert.False(t, s.mustSetup(rw, req, logrus.WithField("test", t.Name()))) resp := rw.Result() - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck assert.Equal(t, 200, resp.StatusCode) assert.Equal(t, "", resp.Header.Get("X-Must-Setup")) assert.Equal(t, "", resp.Header.Get("Location")) diff --git a/managed/services/grafana/client.go b/managed/services/grafana/client.go index 20333cf1bb..e65b196974 100644 --- a/managed/services/grafana/client.go +++ b/managed/services/grafana/client.go @@ -132,7 +132,7 @@ func (c *Client) do(ctx context.Context, method, path, rawQuery string, headers if err != nil { return errors.WithStack(err) } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) if err != nil { diff --git a/managed/services/inventory/inventory_metrics_test.go b/managed/services/inventory/inventory_metrics_test.go index 939ccc7b07..0717edcbd8 100644 --- a/managed/services/inventory/inventory_metrics_test.go +++ b/managed/services/inventory/inventory_metrics_test.go @@ -67,7 +67,7 @@ func TestNewInventoryMetricsCollector(t *testing.T) { require.NoError(t, err) resp, err := client.Do(req) require.NoError(t, err) - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck body, err := io.ReadAll(resp.Body) require.NoError(t, err) diff --git a/managed/services/management/dbaas/components_service.go b/managed/services/management/dbaas/components_service.go index e33497aabe..38441b1226 100644 --- a/managed/services/management/dbaas/components_service.go +++ b/managed/services/management/dbaas/components_service.go @@ -537,7 +537,7 @@ func imageExists(ctx context.Context, image string) (bool, error) { if err != nil { panic(err) } - defer cli.Close() + defer cli.Close() //nolint:errcheck reader, err := cli.ImagePull(ctx, image, types.ImagePullOptions{}) if err != nil { @@ -548,7 +548,7 @@ func imageExists(ctx context.Context, image string) (bool, error) { return false, err } - reader.Close() + reader.Close() //nolint:errcheck return true, nil } diff --git a/managed/services/management/dbaas/version_service_client.go b/managed/services/management/dbaas/version_service_client.go index 934d9bebba..b3aae4d2e0 100644 --- a/managed/services/management/dbaas/version_service_client.go +++ b/managed/services/management/dbaas/version_service_client.go @@ -158,7 +158,7 @@ func (c *VersionServiceClient) Matrix(ctx context.Context, params componentsPara if err != nil { return nil, err } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck body, err := io.ReadAll(resp.Body) if err != nil { return nil, err diff --git a/managed/services/supervisord/logs.go b/managed/services/supervisord/logs.go index 0445ab97cd..fc76f99228 100644 --- a/managed/services/supervisord/logs.go +++ b/managed/services/supervisord/logs.go @@ -374,7 +374,7 @@ func readURL(ctx context.Context, url string) ([]byte, error) { if err != nil { return nil, errors.WithStack(err) } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) if err != nil { diff --git a/managed/services/telemetry/datasources.go b/managed/services/telemetry/datasources.go index 01f5e75996..8eefc3c38e 100644 --- a/managed/services/telemetry/datasources.go +++ b/managed/services/telemetry/datasources.go @@ -88,7 +88,7 @@ func fetchMetricsFromDB(ctx context.Context, l *logrus.Entry, timeout time.Durat if err != nil { return nil, err } - defer rows.Close() + defer rows.Close() //nolint:errcheck columns, err := rows.Columns() if err != nil { diff --git a/managed/services/victoriametrics/victoriametrics.go b/managed/services/victoriametrics/victoriametrics.go index 746e3008d7..3e56210e35 100644 --- a/managed/services/victoriametrics/victoriametrics.go +++ b/managed/services/victoriametrics/victoriametrics.go @@ -440,7 +440,7 @@ func (svc *Service) IsReady(ctx context.Context) error { if err != nil { return errors.WithStack(err) } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) svc.l.Debugf("VM health: %s", b) diff --git a/managed/services/vmalert/vmalert.go b/managed/services/vmalert/vmalert.go index f5c86c03e0..382821243f 100644 --- a/managed/services/vmalert/vmalert.go +++ b/managed/services/vmalert/vmalert.go @@ -159,7 +159,7 @@ func (svc *Service) reload(ctx context.Context) error { if err != nil { return errors.WithStack(err) } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) svc.l.Debugf("VMAlert reload: %s", b) @@ -185,7 +185,7 @@ func (svc *Service) IsReady(ctx context.Context) error { if err != nil { return errors.WithStack(err) } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck b, err := io.ReadAll(resp.Body) svc.l.Debugf("VMAlert health: %s", b) diff --git a/managed/utils/platform/client.go b/managed/utils/platform/client.go index c199e501e0..685c044d92 100644 --- a/managed/utils/platform/client.go +++ b/managed/utils/platform/client.go @@ -259,7 +259,7 @@ func (c *Client) makeRequest(ctx context.Context, accessToken, method, path stri return nil, err } - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck bodyBytes, err := io.ReadAll(resp.Body) if err != nil { diff --git a/qan-api2/db.go b/qan-api2/db.go index 8c87408258..d121ba6cb6 100644 --- a/qan-api2/db.go +++ b/qan-api2/db.go @@ -88,7 +88,7 @@ func createDB(dsn string) error { if err != nil { return err } - defer defaultDB.Close() + defer defaultDB.Close() //nolint:errcheck result, err := defaultDB.Exec(fmt.Sprintf(`CREATE DATABASE %s ENGINE = Atomic`, databaseName)) if err != nil { diff --git a/qan-api2/main.go b/qan-api2/main.go index c155e85c1e..5b151202e4 100644 --- a/qan-api2/main.go +++ b/qan-api2/main.go @@ -186,7 +186,7 @@ func runJSONServer(ctx context.Context, grpcBindF, jsonBindF string) { ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout) if err := server.Shutdown(ctx); err != nil { //nolint:contextcheck l.Errorf("Failed to shutdown gracefully: %s \n", err) - server.Close() + server.Close() //nolint:errcheck } cancel() } @@ -228,7 +228,7 @@ func runDebugServer(ctx context.Context, debugBindF string) { l.Panic(err) } http.HandleFunc("/debug", func(rw http.ResponseWriter, req *http.Request) { - rw.Write(buf.Bytes()) + rw.Write(buf.Bytes()) //nolint:errcheck }) l.Infof("Starting server on http://%s/debug\nRegistered handlers:\n\t%s", debugBindF, strings.Join(handlers, "\n\t")) diff --git a/qan-api2/models/metrics.go b/qan-api2/models/metrics.go index 70dac41689..6daea0014f 100644 --- a/qan-api2/models/metrics.go +++ b/qan-api2/models/metrics.go @@ -1168,7 +1168,7 @@ func (m *Metrics) GetSelectedQueryMetadata(ctx context.Context, periodStartFromS if err != nil { return res, errors.Wrap(err, cannotExecute) } - defer rows.Close() + defer rows.Close() //nolint:errcheck metadata := make(map[string]map[string]struct{}) columnNames, err := rows.Columns() diff --git a/vmproxy/proxy/proxy.go b/vmproxy/proxy/proxy.go index dbc1aa0730..4ad7655ae8 100644 --- a/vmproxy/proxy/proxy.go +++ b/vmproxy/proxy/proxy.go @@ -70,7 +70,7 @@ func failOnInvalidHeader(rw http.ResponseWriter, req *http.Request, headerName s if _, err := parseFilters(filters); err != nil { rw.Header().Set("Content-Type", "text/plain; charset=utf-8") rw.WriteHeader(http.StatusPreconditionFailed) - io.WriteString(rw, fmt.Sprintf("Failed to parse %s header", headerName)) + io.WriteString(rw, fmt.Sprintf("Failed to parse %s header", headerName)) //nolint:errcheck return true } } diff --git a/vmproxy/proxy/proxy_test.go b/vmproxy/proxy/proxy_test.go index daa35dbd5b..4252796010 100644 --- a/vmproxy/proxy/proxy_test.go +++ b/vmproxy/proxy/proxy_test.go @@ -65,7 +65,7 @@ func TestProxy(t *testing.T) { handler.ServeHTTP(rec, req) resp := rec.Result() - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.Equal(t, resp.StatusCode, http.StatusOK) }) @@ -138,7 +138,7 @@ func TestProxy(t *testing.T) { handler.ServeHTTP(rec, req) resp := rec.Result() - defer resp.Body.Close() //nolint:gosec + defer resp.Body.Close() //nolint:gosec,errcheck require.Equal(t, tc.expectedStatus, resp.StatusCode) })