From c6d3714e738287f2368056c90e1c6107f72aa479 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Fri, 31 May 2024 14:37:21 +0200 Subject: [PATCH] build: fix gocritic lint issue assignop --- backend/cache/cache_internal_test.go | 4 ++-- backend/cache/handle.go | 4 ++-- backend/crypt/cipher.go | 4 ++-- backend/imagekit/client/url.go | 2 +- backend/pikpak/helper.go | 2 +- backend/union/union.go | 2 +- cmd/gitannex/gitannex.go | 2 +- fs/accounting/accounting.go | 2 +- fs/config/ui_test.go | 2 +- lib/file/mkdir_windows.go | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/backend/cache/cache_internal_test.go b/backend/cache/cache_internal_test.go index e1baaa155..3bbf46647 100644 --- a/backend/cache/cache_internal_test.go +++ b/backend/cache/cache_internal_test.go @@ -417,7 +417,7 @@ func TestInternalWrappedFsChangeNotSeen(t *testing.T) { if runInstance.rootIsCrypt { data2, err = base64.StdEncoding.DecodeString(cryptedText3Base64) require.NoError(t, err) - expectedSize = expectedSize + 1 // FIXME newline gets in, likely test data issue + expectedSize++ // FIXME newline gets in, likely test data issue } else { data2 = []byte("test content") } @@ -1192,7 +1192,7 @@ func (r *run) updateData(t *testing.T, rootFs fs.Fs, src, data, append string) e func (r *run) cleanSize(t *testing.T, size int64) int64 { if r.rootIsCrypt { denominator := int64(65536 + 16) - size = size - 32 + size -= 32 quotient := size / denominator remainder := size % denominator return (quotient*65536 + remainder - 16) diff --git a/backend/cache/handle.go b/backend/cache/handle.go index a226fa5c4..687e96cec 100644 --- a/backend/cache/handle.go +++ b/backend/cache/handle.go @@ -208,7 +208,7 @@ func (r *Handle) getChunk(chunkStart int64) ([]byte, error) { offset := chunkStart % int64(r.cacheFs().opt.ChunkSize) // we align the start offset of the first chunk to a likely chunk in the storage - chunkStart = chunkStart - offset + chunkStart -= offset r.queueOffset(chunkStart) found := false @@ -327,7 +327,7 @@ func (r *Handle) Seek(offset int64, whence int) (int64, error) { chunkStart := r.offset - (r.offset % int64(r.cacheFs().opt.ChunkSize)) if chunkStart >= int64(r.cacheFs().opt.ChunkSize) { - chunkStart = chunkStart - int64(r.cacheFs().opt.ChunkSize) + chunkStart -= int64(r.cacheFs().opt.ChunkSize) } r.queueOffset(chunkStart) diff --git a/backend/crypt/cipher.go b/backend/crypt/cipher.go index d0f8a658e..57a44b3e3 100644 --- a/backend/crypt/cipher.go +++ b/backend/crypt/cipher.go @@ -329,7 +329,7 @@ func (c *Cipher) obfuscateSegment(plaintext string) string { for _, runeValue := range plaintext { dir += int(runeValue) } - dir = dir % 256 + dir %= 256 // We'll use this number to store in the result filename... var result bytes.Buffer @@ -450,7 +450,7 @@ func (c *Cipher) deobfuscateSegment(ciphertext string) (string, error) { if pos >= 26 { pos -= 6 } - pos = pos - thisdir + pos -= thisdir if pos < 0 { pos += 52 } diff --git a/backend/imagekit/client/url.go b/backend/imagekit/client/url.go index 4589c525d..18738d1e9 100644 --- a/backend/imagekit/client/url.go +++ b/backend/imagekit/client/url.go @@ -56,7 +56,7 @@ func (ik *ImageKit) URL(params URLParam) (string, error) { var expires = strconv.FormatInt(now+params.ExpireSeconds, 10) var path = strings.Replace(resultURL, endpoint, "", 1) - path = path + expires + path += expires mac := hmac.New(sha1.New, []byte(ik.PrivateKey)) mac.Write([]byte(path)) signature := hex.EncodeToString(mac.Sum(nil)) diff --git a/backend/pikpak/helper.go b/backend/pikpak/helper.go index b296900a4..fd1561d7a 100644 --- a/backend/pikpak/helper.go +++ b/backend/pikpak/helper.go @@ -347,7 +347,7 @@ func calcGcid(r io.Reader, size int64) (string, error) { calcBlockSize := func(j int64) int64 { var psize int64 = 0x40000 for float64(j)/float64(psize) > 0x200 && psize < 0x200000 { - psize = psize << 1 + psize <<= 1 } return psize } diff --git a/backend/union/union.go b/backend/union/union.go index 3f1d51d16..f1922eda7 100644 --- a/backend/union/union.go +++ b/backend/union/union.go @@ -903,7 +903,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e // Backward compatible to old config if len(opt.Upstreams) == 0 && len(opt.Remotes) > 0 { for i := 0; i < len(opt.Remotes)-1; i++ { - opt.Remotes[i] = opt.Remotes[i] + ":ro" + opt.Remotes[i] += ":ro" } opt.Upstreams = opt.Remotes } diff --git a/cmd/gitannex/gitannex.go b/cmd/gitannex/gitannex.go index b8ef8b78f..287adc7ae 100644 --- a/cmd/gitannex/gitannex.go +++ b/cmd/gitannex/gitannex.go @@ -157,7 +157,7 @@ type server struct { } func (s *server) sendMsg(msg string) { - msg = msg + "\n" + msg += "\n" if _, err := io.WriteString(s.writer, msg); err != nil { panic(err) } diff --git a/fs/accounting/accounting.go b/fs/accounting/accounting.go index 12c7db32f..d7d7e02dd 100644 --- a/fs/accounting/accounting.go +++ b/fs/accounting/accounting.go @@ -527,7 +527,7 @@ func (acc *Account) String() string { } if acc.ci.DataRateUnit == "bits" { - cur = cur * 8 + cur *= 8 } percentageDone := 0 diff --git a/fs/config/ui_test.go b/fs/config/ui_test.go index f24f2891f..eac3a9bb0 100644 --- a/fs/config/ui_test.go +++ b/fs/config/ui_test.go @@ -88,7 +88,7 @@ func testConfigFile(t *testing.T, options []fs.Option, configFileName string) fu func makeReadLine(answers []string) func() string { i := 0 return func() string { - i = i + 1 + i++ return answers[i-1] } } diff --git a/lib/file/mkdir_windows.go b/lib/file/mkdir_windows.go index d5a875ec3..4b5ba4f12 100644 --- a/lib/file/mkdir_windows.go +++ b/lib/file/mkdir_windows.go @@ -42,7 +42,7 @@ func MkdirAll(path string, perm os.FileMode) error { // In extended-length form without trailing slash ("\\?\C:"), os.Stat // and os.Mkdir both fails. With trailing slash ("\\?\C:\") works, // and regular paths with or without it ("C:" and "C:\") both works. - path = path + string(os.PathSeparator) + path += string(os.PathSeparator) } else { // See if there is a parent to be created first. // Not when path refer to a drive's root directory, because we don't