Skip to content

Commit bf2cda0

Browse files
committed
small fixes after qodana analysis
1 parent 672e680 commit bf2cda0

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

pkg/backup/backup_shard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func newReplicaDeterminer(q querier, sf shardFunc) *replicaDeterminer {
167167

168168
// getReplicaState obtains the local replication state through a query to `system.replicas`
169169
func (rd *replicaDeterminer) getReplicaState(ctx context.Context) ([]tableReplicaMetadata, error) {
170-
md := []tableReplicaMetadata{}
170+
var md []tableReplicaMetadata
171171
// TODO: Change query to pull replica_is_active after upgrading to clickhouse-go v2
172172
query := "SELECT t.database, t.name AS table, r.replica_name, arraySort(mapKeys(mapFilter((replica, active) -> (active == 1), r.replica_is_active))) AS active_replicas FROM system.tables t LEFT JOIN system.replicas r ON t.database = r.database AND t.name = r.table"
173173
if err := rd.q.SelectContext(ctx, &md, query); err != nil {

pkg/backup/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (b *Backuper) skipIfTheSameRemoteBackupPresent(ctx context.Context, backupN
258258
} else {
259259
for _, remoteBackup := range remoteList {
260260
if remoteBackup.BackupName == backupName {
261-
if tags == "" || (tags != "" && strings.Contains(remoteBackup.Tags, tags)) {
261+
if tags == "" || strings.Contains(remoteBackup.Tags, tags) {
262262
return true, nil
263263
}
264264
}

pkg/log_helper/log_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (w *CustomWriter) Write(p []byte) (n int, err error) {
119119

120120
// Iterate over all fields to find custom fields - zero allocations
121121
hasCustomFields := false
122-
jsonparser.ObjectEach(p, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error {
122+
_ = jsonparser.ObjectEach(p, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error {
123123
keyStr := string(key)
124124
if !systemFields[keyStr] {
125125
if !hasCustomFields {

pkg/storage/azblob/chunkwriting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func copyFromReader(ctx context.Context, from io.Reader, to blockWriter, o azb.U
6666
}
6767
}
6868
// If the error is not EOF, then we have a problem.
69-
if err != nil && !errors.Is(err, io.EOF) {
69+
if !errors.Is(err, io.EOF) {
7070
return nil, err
7171
}
7272

@@ -145,7 +145,7 @@ func (c *copier) sendChunk() error {
145145
id: c.id.next(),
146146
}
147147
return nil
148-
case err != nil && (err == io.EOF || errors.Is(err, io.ErrUnexpectedEOF)) && n == 0:
148+
case (err == io.EOF || errors.Is(err, io.ErrUnexpectedEOF)) && n == 0:
149149
return io.EOF
150150
}
151151

pkg/storage/general.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ func (bd *BackupDestination) DownloadCompressedStream(ctx context.Context, remot
304304
compressionFormat = strings.Replace(path.Ext(remotePath), ".", "", -1)
305305
}
306306
downloadedBytes := int64(0)
307-
z, getArchieveReaderErr := getArchiveReader(compressionFormat)
308-
if getArchieveReaderErr != nil {
309-
return 0, getArchieveReaderErr
307+
z, getArchiveReaderErr := getArchiveReader(compressionFormat)
308+
if getArchiveReaderErr != nil {
309+
return 0, getArchiveReaderErr
310310
}
311311
if extractErr := z.Extract(ctx, bufReader, nil, func(ctx context.Context, file archiver.File) error {
312312
src, openErr := file.Open()

pkg/storage/s3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ func (s *S3) getObjectAllVersions(ctx context.Context, key string) ([]string, er
405405
if s.Config.RequestPayer != "" {
406406
listParams.RequestPayer = s3types.RequestPayer(s.Config.RequestPayer)
407407
}
408-
versions := []string{}
408+
var versions []string
409409
pager := s3.NewListObjectVersionsPaginator(s.client, listParams)
410410
for pager.HasMorePages() {
411411
page, err := pager.NextPage(ctx)

0 commit comments

Comments
 (0)