Skip to content

Commit 1641c45

Browse files
committed
Fix remaining lint issues
- pex_test: copy pexState fields individually to avoid copying sync.RWMutex - fuse errors: add nolint pragmas for deprecated fuse error types - Replace deprecated VerifyData with VerifyDataContext(context.TODO()) - Replace deprecated math/rand.Read with math/rand/v2.ChaCha8.Read - Convert if-else chain to tagged switch in file-io-mmap - Add nolint for intentionally empty branches with comments - Add nolint for table.addIndex (generics false positive, implements tableInterface) - Fix unusedresult in ut-holepunch test, ineffassign in requesting test - Remove redundant type annotation in torrent.go
1 parent 94885b4 commit 1641c45

File tree

18 files changed

+38
-25
lines changed

18 files changed

+38
-25
lines changed

client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"encoding/binary"
66
"fmt"
77
"io"
8-
"math/rand"
8+
rand "math/rand/v2"
99
"net"
1010
"net/netip"
1111
"os"
@@ -161,7 +161,7 @@ func TestMergingTrackersByAddingSpecs(t *testing.T) {
161161
require.NoError(t, err)
162162
defer cl.Close()
163163
spec := TorrentSpec{}
164-
rand.Read(spec.InfoHash[:])
164+
rand.NewChaCha8([32]byte{}).Read(spec.InfoHash[:])
165165
T, new, _ := cl.AddTorrentSpec(&spec)
166166
if !new {
167167
t.FailNow()

fs/file_handle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ func (me fileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse
8080
case <-readDone:
8181
return readErr
8282
case <-me.fn.FS.destroyed:
83-
return fuse.EIO
83+
return fuse.EIO //nolint:staticcheck // fuse error type
8484
case <-ctx.Done():
85-
return fuse.EINTR
85+
return fuse.EINTR //nolint:staticcheck // fuse error type
8686
}
8787
}
8888

fs/torrentfs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (dn dirNode) Lookup(_ context.Context, name string) (fusefs.Node, error) {
131131
if dir {
132132
return dirNode{n}, nil
133133
}
134-
return nil, fuse.ENOENT
134+
return nil, fuse.ENOENT //nolint:staticcheck // fuse error type
135135
}
136136

137137
func (dn dirNode) Attr(ctx context.Context, attr *fuse.Attr) error {
@@ -158,7 +158,7 @@ func (rn rootNode) Lookup(ctx context.Context, name string) (_node fusefs.Node,
158158
break
159159
}
160160
if _node == nil {
161-
err = fuse.ENOENT
161+
err = fuse.ENOENT //nolint:staticcheck // fuse error type
162162
}
163163
return
164164
}

fs/torrentfs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func TestDownloadOnDemand(t *testing.T) {
180180
go func() {
181181
// Wait until we get the metainfo, then check for the data.
182182
<-seederTorrent.GotInfo()
183-
seederTorrent.VerifyData()
183+
seederTorrent.VerifyDataContext(context.TODO())
184184
}()
185185
cfg = torrent.NewDefaultClientConfig()
186186
cfg.DisableTrackers = true

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/anacrolix/dht/v2 v2.23.0
1313
github.com/anacrolix/envpprof v1.4.0
1414
github.com/anacrolix/fuse v0.3.2
15-
github.com/anacrolix/generics v0.1.1-0.20251125230353-15d98d46693b
15+
github.com/anacrolix/generics v0.2.0
1616
github.com/anacrolix/go-libutp v1.3.2
1717
github.com/anacrolix/gostdapp v0.2.1-0.20251125125325-fbac3f25c013
1818
github.com/anacrolix/log v0.17.1-0.20251118025802-918f1157b7bb

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ github.com/anacrolix/fuse v0.3.2/go.mod h1:vN3X/6E+uHNjg5F8Oy9FD9I+pYxeDWeB8mNjI
8787
github.com/anacrolix/generics v0.0.0-20230113004304-d6428d516633/go.mod h1:ff2rHB/joTV03aMSSn/AZNnaIpUw0h3njetGsaXcMy8=
8888
github.com/anacrolix/generics v0.1.1-0.20251125230353-15d98d46693b h1:Kuvx/A/TTJuT9x8mn7DeGx2KW9tWn1LI8bira67xdT0=
8989
github.com/anacrolix/generics v0.1.1-0.20251125230353-15d98d46693b/go.mod h1:NGehhfeXJPBujPx0s6cstSj8B+TERsTY32Xckfx5ftc=
90+
github.com/anacrolix/generics v0.2.0 h1:gPwGOs14irokFN9kUP1i1A0Bn0FPT7/hWWD3hHKSKNw=
91+
github.com/anacrolix/generics v0.2.0/go.mod h1:NGehhfeXJPBujPx0s6cstSj8B+TERsTY32Xckfx5ftc=
9092
github.com/anacrolix/go-libutp v1.3.2 h1:WswiaxTIogchbkzNgGHuHRfbrYLpv4o290mlvcx+++M=
9193
github.com/anacrolix/go-libutp v1.3.2/go.mod h1:fCUiEnXJSe3jsPG554A200Qv+45ZzIIyGEvE56SHmyA=
9294
github.com/anacrolix/gostdapp v0.2.1-0.20251125125325-fbac3f25c013 h1:fdjruiqT1gnhzeX9kzumnGaluIlRDq6dZXZDaUUiK1k=

internal/indexed/misc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func NewFullMappedIndex[F, T comparable](
6060
return index
6161
}
6262

63+
//nolint:unused // false positive with generics: implements tableInterface, called via interface
6364
func (me *table[R]) addIndex(_ genericRelation, trigger triggerFunc[R]) {
6465
me.indexTriggers = append(me.indexTriggers, trigger)
6566
}

ltep_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package torrent_test
22

33
import (
4-
"math/rand"
4+
rand "math/rand/v2"
55
"strconv"
66
"testing"
77

@@ -112,7 +112,7 @@ func TestUserLtep(t *testing.T) {
112112
qt.Assert(t, qt.IsNil(err))
113113
defer cl2.Close()
114114
addOpts := AddTorrentOpts{}
115-
rand.Read(addOpts.InfoHash[:])
115+
rand.NewChaCha8([32]byte{}).Read(addOpts.InfoHash[:])
116116
t1, _ := cl1.AddTorrentOpt(addOpts)
117117
t2, _ := cl2.AddTorrentOpt(addOpts)
118118
defer testutil.ExportStatusWriter(cl1, "cl1", t)()

peer_protocol/ut-holepunch/err-code_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ import (
66
)
77

88
func TestUnknownErrCodeError(t *testing.T) {
9-
ErrCode(rand.Uint32()).Error()
9+
_ = ErrCode(rand.Uint32()).Error()
1010
}

peerconn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ func (c *PeerConn) mainReadLoop() (err error) {
915915
}
916916
if !c.fastEnabled() {
917917
c.deleteAllRequests("choked by non-fast PeerConn")
918-
} else {
918+
} else { //nolint:staticcheck // SA9003: intentionally empty, see comment below
919919
// We don't decrement pending requests here, let's wait for the peer to either
920920
// reject or satisfy the outstanding requests. Additionally, some peers may unchoke
921921
// us and resume where they left off, we don't want to have piled on to those chunks

0 commit comments

Comments
 (0)