From dc41978743aac610d4a734b2afd65a0eec0bf4b7 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Wed, 9 Aug 2023 10:55:24 +0300 Subject: [PATCH] all: fix golangci failures Change-Id: I07421388d53c837e35a4727cead26fc21c324d04 --- cmd/storj-sim/process.go | 3 ++- satellite/admin/project.go | 4 ++-- satellite/console/consoleweb/consoleapi/auth_test.go | 8 +++----- satellite/metabase/commit_object.go | 3 ++- satellite/satellitedb/overlaycache.go | 4 ++-- storagenode/pieces/filewalker.go | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/storj-sim/process.go b/cmd/storj-sim/process.go index 0951bf4a1ac1..483c004eb40f 100644 --- a/cmd/storj-sim/process.go +++ b/cmd/storj-sim/process.go @@ -255,7 +255,8 @@ func (process *Process) Exec(ctx context.Context, command string) (err error) { if _, ok := process.Arguments[command]; !ok { fmt.Fprintf(process.processes.Output, "%s running: %s\n", process.Name, command) - return + //TODO: This doesn't look right, but keeping the same behaviour as before. + return nil } cmd := exec.CommandContext(ctx, executable, process.Arguments[command]...) diff --git a/satellite/admin/project.go b/satellite/admin/project.go index c8581bd16d9b..ca59124693b5 100644 --- a/satellite/admin/project.go +++ b/satellite/admin/project.go @@ -656,7 +656,7 @@ func (server *Server) checkUsage(ctx context.Context, w http.ResponseWriter, pro if err != nil { sendJSONError(w, "unable to get project details", err.Error(), http.StatusInternalServerError) - return + return false } // If user is paid tier, check the usage limit, otherwise it is ok to delete it. @@ -664,7 +664,7 @@ func (server *Server) checkUsage(ctx context.Context, w http.ResponseWriter, pro if err != nil { sendJSONError(w, "unable to project owner tier", err.Error(), http.StatusInternalServerError) - return + return false } if paid { // check current month usage and do not allow deletion if usage exists diff --git a/satellite/console/consoleweb/consoleapi/auth_test.go b/satellite/console/consoleweb/consoleapi/auth_test.go index 2404465328bd..30ec2852c790 100644 --- a/satellite/console/consoleweb/consoleapi/auth_test.go +++ b/satellite/console/consoleweb/consoleapi/auth_test.go @@ -199,16 +199,14 @@ func TestDeleteAccount(t *testing.T) { authController := consoleapi.NewAuth(log, nil, nil, nil, nil, nil, "", "", "", "", "", "") authController.DeleteAccount(rr, r) - //nolint:bodyclose result := rr.Result() - defer func() { - err := result.Body.Close() - require.NoError(t, err) - }() body, err := io.ReadAll(result.Body) require.NoError(t, err) + err = result.Body.Close() + require.NoError(t, err) + return result.StatusCode, body } diff --git a/satellite/metabase/commit_object.go b/satellite/metabase/commit_object.go index e38c545a01c1..b2db6adba117 100644 --- a/satellite/metabase/commit_object.go +++ b/satellite/metabase/commit_object.go @@ -264,8 +264,9 @@ func convertToFinalSegments(segmentsInDatabase []segmentInfoForCommit) (commit [ // updateSegmentOffsets updates segment offsets that didn't match the database state. func updateSegmentOffsets(ctx context.Context, tx tagsql.Tx, streamID uuid.UUID, updates []segmentToCommit) (err error) { defer mon.Task()(&ctx)(&err) + if len(updates) == 0 { - return + return nil } // We may be able to skip this, if the database state have been already submitted diff --git a/satellite/satellitedb/overlaycache.go b/satellite/satellitedb/overlaycache.go index 2dd9322b3616..06d47e3f0ad7 100644 --- a/satellite/satellitedb/overlaycache.go +++ b/satellite/satellitedb/overlaycache.go @@ -363,7 +363,7 @@ func (cache *overlaycache) GetOfflineNodesForEmail(ctx context.Context, offlineW LIMIT $4 `, now.Add(-offlineWindow), now.Add(-cutoff), now.Add(-cooldown), limit) if err != nil { - return + return nil, Error.Wrap(err) } defer func() { err = errs.Combine(err, rows.Close()) }() @@ -374,7 +374,7 @@ func (cache *overlaycache) GetOfflineNodesForEmail(ctx context.Context, offlineW err = rows.Scan(&idBytes, &email) nodeID, err = storj.NodeIDFromBytes(idBytes) if err != nil { - return + return nil, Error.Wrap(err) } nodes[nodeID] = email } diff --git a/storagenode/pieces/filewalker.go b/storagenode/pieces/filewalker.go index ed6e17904054..cb7c88422069 100644 --- a/storagenode/pieces/filewalker.go +++ b/storagenode/pieces/filewalker.go @@ -140,7 +140,7 @@ func (fw *FileWalker) WalkSatellitePiecesToTrash(ctx context.Context, satelliteI defer mon.Task()(&ctx)(&err) if filter == nil { - return + return nil, 0, 0, Error.New("filter not specified") } err = fw.WalkSatellitePieces(ctx, satelliteID, func(access StoredPieceAccess) error {