From 7257cd2e5f0915ddfc688311ad796fd87abbb971 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 21 Sep 2025 22:14:25 +0200 Subject: [PATCH] extra linters --- .golangci.yml | 3 +++ cmd/restic/cmd_backup_integration_test.go | 2 -- cmd/restic/cmd_tag_integration_test.go | 1 - internal/backend/limiter/static_limiter_test.go | 2 +- internal/backend/sftp/sftp.go | 1 - internal/checker/checker_test.go | 1 - internal/fs/stat.go | 2 +- internal/restic/node.go | 1 - 8 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index f29d8fc21..c90fb3afa 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,8 +3,10 @@ linters: # only enable the linters listed below default: none enable: + - asciicheck # ensure that http response bodies are closed - bodyclose + - copyloopvar # make sure all errors returned by functions are handled - errcheck # examine code and report suspicious constructs, such as Printf calls whose @@ -14,6 +16,7 @@ linters: - importas # detect when assignments to existing variables are not used - ineffassign + - nolintlint # make sure names and comments are used according to the conventions - revive # run static analysis and find errors diff --git a/cmd/restic/cmd_backup_integration_test.go b/cmd/restic/cmd_backup_integration_test.go index ba9ea2e62..74a979024 100644 --- a/cmd/restic/cmd_backup_integration_test.go +++ b/cmd/restic/cmd_backup_integration_test.go @@ -461,7 +461,6 @@ func TestIncrementalBackup(t *testing.T) { t.Logf("repository grown by %d bytes", stat3.size-stat2.size) } -// nolint: staticcheck // false positive nil pointer dereference check func TestBackupTags(t *testing.T) { env, cleanup := withTestEnvironment(t) defer cleanup() @@ -497,7 +496,6 @@ func TestBackupTags(t *testing.T) { "expected parent to be %v, got %v", parent.ID, newest.Parent) } -// nolint: staticcheck // false positive nil pointer dereference check func TestBackupProgramVersion(t *testing.T) { env, cleanup := withTestEnvironment(t) defer cleanup() diff --git a/cmd/restic/cmd_tag_integration_test.go b/cmd/restic/cmd_tag_integration_test.go index 53360ca84..5d58f89c4 100644 --- a/cmd/restic/cmd_tag_integration_test.go +++ b/cmd/restic/cmd_tag_integration_test.go @@ -12,7 +12,6 @@ func testRunTag(t testing.TB, opts TagOptions, gopts GlobalOptions) { rtest.OK(t, runTag(context.TODO(), opts, gopts, nil, []string{})) } -// nolint: staticcheck // false positive nil pointer dereference check func TestTag(t *testing.T) { env, cleanup := withTestEnvironment(t) defer cleanup() diff --git a/internal/backend/limiter/static_limiter_test.go b/internal/backend/limiter/static_limiter_test.go index bc9823435..5f95c27ff 100644 --- a/internal/backend/limiter/static_limiter_test.go +++ b/internal/backend/limiter/static_limiter_test.go @@ -118,7 +118,7 @@ func TestRoundTripperReader(t *testing.T) { test.Assert(t, bytes.Equal(data, out.Bytes()), "data ping-pong failed") } -// nolint:bodyclose // the http response is just a mock +//nolint:bodyclose // the http response is just a mock func TestRoundTripperCornerCases(t *testing.T) { limiter := NewStaticLimiter(Limits{42 * 1024, 42 * 1024}) diff --git a/internal/backend/sftp/sftp.go b/internal/backend/sftp/sftp.go index 78757a249..174877b26 100644 --- a/internal/backend/sftp/sftp.go +++ b/internal/backend/sftp/sftp.go @@ -176,7 +176,6 @@ func (r *SFTP) mkdirAllDataSubdirs(ctx context.Context, nconn uint) error { g.SetLimit(int(nconn)) for _, d := range r.Paths() { - d := d g.Go(func() error { // First try Mkdir. For most directories in Paths, this takes one // round trip, not counting duplicate parent creations causes by diff --git a/internal/checker/checker_test.go b/internal/checker/checker_test.go index 64f9b61ff..29538e8ec 100644 --- a/internal/checker/checker_test.go +++ b/internal/checker/checker_test.go @@ -669,7 +669,6 @@ func benchmarkSnapshotScaling(t *testing.B, newSnapshots int) { func BenchmarkCheckerSnapshotScaling(b *testing.B) { counts := []int{50, 100, 200} for _, count := range counts { - count := count b.Run(strconv.Itoa(count), func(b *testing.B) { benchmarkSnapshotScaling(b, count) }) diff --git a/internal/fs/stat.go b/internal/fs/stat.go index bd3993f41..4c55e6105 100644 --- a/internal/fs/stat.go +++ b/internal/fs/stat.go @@ -25,7 +25,7 @@ type ExtendedFileInfo struct { ModTime time.Time // last (content) modification time stamp ChangeTime time.Time // last status change time stamp - // nolint:unused // only used on Windows + //nolint:unused // only used on Windows sys any // Value returned by os.FileInfo.Sys() } diff --git a/internal/restic/node.go b/internal/restic/node.go index 8e460b2b1..640368768 100644 --- a/internal/restic/node.go +++ b/internal/restic/node.go @@ -413,7 +413,6 @@ func handleUnknownGenericAttributeFound(genericAttributeType GenericAttributeTyp // HandleAllUnknownGenericAttributesFound performs validations for all generic attributes of a node. // This is not used on windows currently because windows has handling for generic attributes. -// nolint:unused func HandleAllUnknownGenericAttributesFound(attributes map[GenericAttributeType]json.RawMessage, warn func(msg string)) error { for name := range attributes { handleUnknownGenericAttributeFound(name, warn)