From 5130c414daae70de2d0c786d6bea7e199d5f3426 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 28 Jul 2022 17:17:29 +0200 Subject: [PATCH] all: Unused parameter should be replaced by underscore (#8464) Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- cmd/stdiscosrv/apisrv.go | 4 +-- cmd/stdiscosrv/replication.go | 2 +- cmd/strelaysrv/listener.go | 2 +- cmd/strelaysrv/status.go | 2 +- cmd/syncthing/cli/config.go | 2 +- cmd/ursrv/main.go | 8 +++--- lib/connections/quic_listen.go | 4 +-- lib/connections/relay_listen.go | 2 +- lib/db/schemaupdater.go | 2 +- lib/discover/cache_test.go | 4 +-- lib/events/events.go | 8 +++--- lib/fs/basicfs.go | 2 +- lib/fs/errorfs.go | 48 +++++++++++++++---------------- lib/fs/fakefs.go | 14 ++++----- lib/fs/mtimefs_test.go | 2 +- lib/model/model.go | 2 +- lib/nat/service.go | 2 +- lib/pmp/pmp.go | 2 +- lib/protocol/benchmark_test.go | 10 +++---- lib/protocol/common_test.go | 4 +-- lib/relay/protocol/packets_xdr.go | 24 ++++++++-------- lib/scanner/blocks.go | 2 +- lib/scanner/virtualfs_test.go | 6 ++-- lib/scanner/walk.go | 2 +- lib/scanner/walk_test.go | 2 +- lib/stun/filter.go | 4 +-- lib/testutils/testutils.go | 4 +-- lib/upnp/upnp.go | 2 +- lib/util/semaphore_test.go | 2 +- lib/versioner/external.go | 2 +- lib/watchaggregator/aggregator.go | 2 +- meta/metalint_test.go | 2 +- 32 files changed, 90 insertions(+), 90 deletions(-) diff --git a/cmd/stdiscosrv/apisrv.go b/cmd/stdiscosrv/apisrv.go index ad2b1f478..1140e073d 100644 --- a/cmd/stdiscosrv/apisrv.go +++ b/cmd/stdiscosrv/apisrv.go @@ -68,7 +68,7 @@ func newAPISrv(addr string, cert tls.Certificate, db database, repl replicator, } } -func (s *apiSrv) Serve(ctx context.Context) error { +func (s *apiSrv) Serve(_ context.Context) error { if s.useHTTP { listener, err := net.Listen("tcp", s.addr) if err != nil { @@ -302,7 +302,7 @@ func (s *apiSrv) handleAnnounce(deviceID protocol.DeviceID, addresses []string) return s.db.merge(key, dbAddrs, seen) } -func handlePing(w http.ResponseWriter, r *http.Request) { +func handlePing(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(204) } diff --git a/cmd/stdiscosrv/replication.go b/cmd/stdiscosrv/replication.go index f84e97ecc..72701ba94 100644 --- a/cmd/stdiscosrv/replication.go +++ b/cmd/stdiscosrv/replication.go @@ -135,7 +135,7 @@ func (s *replicationSender) String() string { return fmt.Sprintf("replicationSender(%q)", s.dst) } -func (s *replicationSender) send(key string, ps []DatabaseAddress, seen int64) { +func (s *replicationSender) send(key string, ps []DatabaseAddress, _ int64) { item := ReplicationRecord{ Key: key, Addresses: ps, diff --git a/cmd/strelaysrv/listener.go b/cmd/strelaysrv/listener.go index d1fa0d76d..d9df57b12 100644 --- a/cmd/strelaysrv/listener.go +++ b/cmd/strelaysrv/listener.go @@ -23,7 +23,7 @@ var ( numConnections int64 ) -func listener(proto, addr string, config *tls.Config) { +func listener(_, addr string, config *tls.Config) { tcpListener, err := net.Listen("tcp", addr) if err != nil { log.Fatalln(err) diff --git a/cmd/strelaysrv/status.go b/cmd/strelaysrv/status.go index 8079af572..838d653b0 100644 --- a/cmd/strelaysrv/status.go +++ b/cmd/strelaysrv/status.go @@ -36,7 +36,7 @@ func statusService(addr string) { } } -func getStatus(w http.ResponseWriter, r *http.Request) { +func getStatus(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") status := make(map[string]interface{}) diff --git a/cmd/syncthing/cli/config.go b/cmd/syncthing/cli/config.go index 36150d539..fbcf6dec2 100644 --- a/cmd/syncthing/cli/config.go +++ b/cmd/syncthing/cli/config.go @@ -60,7 +60,7 @@ func (h *configHandler) configBefore(c *cli.Context) error { return h.err } -func (h *configHandler) configAfter(c *cli.Context) error { +func (h *configHandler) configAfter(_ *cli.Context) error { if h.err != nil { // Error was already returned in configBefore return nil diff --git a/cmd/ursrv/main.go b/cmd/ursrv/main.go index 0d24ee1be..34abce77b 100644 --- a/cmd/ursrv/main.go +++ b/cmd/ursrv/main.go @@ -284,7 +284,7 @@ func rootHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) { } } -func locationsHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) { +func locationsHandler(db *sql.DB, w http.ResponseWriter, _ *http.Request) { cacheMut.Lock() defer cacheMut.Unlock() @@ -377,7 +377,7 @@ func summaryHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) { w.Write(bs) } -func movementHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) { +func movementHandler(db *sql.DB, w http.ResponseWriter, _ *http.Request) { s, err := getMovement(db) if err != nil { log.Println("movementHandler:", err) @@ -396,7 +396,7 @@ func movementHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) { w.Write(bs) } -func performanceHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) { +func performanceHandler(db *sql.DB, w http.ResponseWriter, _ *http.Request) { s, err := getPerformance(db) if err != nil { log.Println("performanceHandler:", err) @@ -415,7 +415,7 @@ func performanceHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) { w.Write(bs) } -func blockStatsHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) { +func blockStatsHandler(db *sql.DB, w http.ResponseWriter, _ *http.Request) { s, err := getBlockStats(db) if err != nil { log.Println("blockStatsHandler:", err) diff --git a/lib/connections/quic_listen.go b/lib/connections/quic_listen.go index ed0eeae4e..a2a324d4e 100644 --- a/lib/connections/quic_listen.go +++ b/lib/connections/quic_listen.go @@ -218,7 +218,7 @@ func (f *quicListenerFactory) Valid(config.Configuration) error { return nil } -func (f *quicListenerFactory) New(uri *url.URL, cfg config.Wrapper, tlsCfg *tls.Config, conns chan internalConn, natService *nat.Service, registry *registry.Registry) genericListener { +func (f *quicListenerFactory) New(uri *url.URL, cfg config.Wrapper, tlsCfg *tls.Config, conns chan internalConn, _ *nat.Service, registry *registry.Registry) genericListener { l := &quicListener{ uri: fixupPort(uri, config.DefaultQUICPort), cfg: cfg, @@ -232,6 +232,6 @@ func (f *quicListenerFactory) New(uri *url.URL, cfg config.Wrapper, tlsCfg *tls. return l } -func (quicListenerFactory) Enabled(cfg config.Configuration) bool { +func (quicListenerFactory) Enabled(_ config.Configuration) bool { return true } diff --git a/lib/connections/relay_listen.go b/lib/connections/relay_listen.go index 035ba787a..4de6bc8ea 100644 --- a/lib/connections/relay_listen.go +++ b/lib/connections/relay_listen.go @@ -178,7 +178,7 @@ func (t *relayListener) NATType() string { type relayListenerFactory struct{} -func (f *relayListenerFactory) New(uri *url.URL, cfg config.Wrapper, tlsCfg *tls.Config, conns chan internalConn, natService *nat.Service, _ *registry.Registry) genericListener { +func (f *relayListenerFactory) New(uri *url.URL, cfg config.Wrapper, tlsCfg *tls.Config, conns chan internalConn, _ *nat.Service, _ *registry.Registry) genericListener { t := &relayListener{ uri: uri, cfg: cfg, diff --git a/lib/db/schemaupdater.go b/lib/db/schemaupdater.go index 95d021296..ccf71b685 100644 --- a/lib/db/schemaupdater.go +++ b/lib/db/schemaupdater.go @@ -519,7 +519,7 @@ func (db *schemaUpdater) updateSchema6to7(_ int) error { return t.Commit() } -func (db *schemaUpdater) updateSchemaTo9(prev int) error { +func (db *schemaUpdater) updateSchemaTo9(_ int) error { // Loads and rewrites all files with blocks, to deduplicate block lists. t, err := db.newReadWriteTransaction() diff --git a/lib/discover/cache_test.go b/lib/discover/cache_test.go index 130e7c97d..f23a9b72e 100644 --- a/lib/discover/cache_test.go +++ b/lib/discover/cache_test.go @@ -79,7 +79,7 @@ type fakeDiscovery struct { addresses []string } -func (f *fakeDiscovery) Lookup(_ context.Context, deviceID protocol.DeviceID) (addresses []string, err error) { +func (f *fakeDiscovery) Lookup(_ context.Context, _ protocol.DeviceID) (addresses []string, err error) { return f.addresses, nil } @@ -127,7 +127,7 @@ type slowDiscovery struct { started chan struct{} } -func (f *slowDiscovery) Lookup(_ context.Context, deviceID protocol.DeviceID) (addresses []string, err error) { +func (f *slowDiscovery) Lookup(_ context.Context, _ protocol.DeviceID) (addresses []string, err error) { close(f.started) time.Sleep(f.delay) return nil, nil diff --git a/lib/events/events.go b/lib/events/events.go index 3a2f52511..eec58ee7f 100644 --- a/lib/events/events.go +++ b/lib/events/events.go @@ -551,11 +551,11 @@ type noopLogger struct{} var NoopLogger Logger = &noopLogger{} -func (*noopLogger) Serve(ctx context.Context) error { return nil } +func (*noopLogger) Serve(_ context.Context) error { return nil } -func (*noopLogger) Log(t EventType, data interface{}) {} +func (*noopLogger) Log(_ EventType, _ interface{}) {} -func (*noopLogger) Subscribe(mask EventType) Subscription { +func (*noopLogger) Subscribe(_ EventType) Subscription { return &noopSubscription{} } @@ -565,7 +565,7 @@ func (*noopSubscription) C() <-chan Event { return nil } -func (*noopSubscription) Poll(timeout time.Duration) (Event, error) { +func (*noopSubscription) Poll(_ time.Duration) (Event, error) { return Event{}, errNoop } diff --git a/lib/fs/basicfs.go b/lib/fs/basicfs.go index a6e2b17e7..9aeb10619 100644 --- a/lib/fs/basicfs.go +++ b/lib/fs/basicfs.go @@ -265,7 +265,7 @@ func (f *BasicFilesystem) Create(name string) (File, error) { return basicFile{fd, name}, err } -func (f *BasicFilesystem) Walk(root string, walkFn WalkFunc) error { +func (f *BasicFilesystem) Walk(_ string, _ WalkFunc) error { // implemented in WalkFilesystem return errors.New("not implemented") } diff --git a/lib/fs/errorfs.go b/lib/fs/errorfs.go index 06564ba3d..853e3f48b 100644 --- a/lib/fs/errorfs.go +++ b/lib/fs/errorfs.go @@ -19,42 +19,42 @@ type errorFilesystem struct { uri string } -func (fs *errorFilesystem) Chmod(name string, mode FileMode) error { return fs.err } -func (fs *errorFilesystem) Lchown(name, uid, gid string) error { return fs.err } -func (fs *errorFilesystem) Chtimes(name string, atime time.Time, mtime time.Time) error { +func (fs *errorFilesystem) Chmod(_ string, _ FileMode) error { return fs.err } +func (fs *errorFilesystem) Lchown(_, _, _ string) error { return fs.err } +func (fs *errorFilesystem) Chtimes(_ string, _ time.Time, _ time.Time) error { return fs.err } -func (fs *errorFilesystem) Create(name string) (File, error) { return nil, fs.err } -func (fs *errorFilesystem) CreateSymlink(target, name string) error { return fs.err } -func (fs *errorFilesystem) DirNames(name string) ([]string, error) { return nil, fs.err } -func (fs *errorFilesystem) Lstat(name string) (FileInfo, error) { return nil, fs.err } -func (fs *errorFilesystem) Mkdir(name string, perm FileMode) error { return fs.err } -func (fs *errorFilesystem) MkdirAll(name string, perm FileMode) error { return fs.err } -func (fs *errorFilesystem) Open(name string) (File, error) { return nil, fs.err } +func (fs *errorFilesystem) Create(_ string) (File, error) { return nil, fs.err } +func (fs *errorFilesystem) CreateSymlink(_, _ string) error { return fs.err } +func (fs *errorFilesystem) DirNames(_ string) ([]string, error) { return nil, fs.err } +func (fs *errorFilesystem) Lstat(_ string) (FileInfo, error) { return nil, fs.err } +func (fs *errorFilesystem) Mkdir(_ string, _ FileMode) error { return fs.err } +func (fs *errorFilesystem) MkdirAll(_ string, _ FileMode) error { return fs.err } +func (fs *errorFilesystem) Open(_ string) (File, error) { return nil, fs.err } func (fs *errorFilesystem) OpenFile(string, int, FileMode) (File, error) { return nil, fs.err } -func (fs *errorFilesystem) ReadSymlink(name string) (string, error) { return "", fs.err } -func (fs *errorFilesystem) Remove(name string) error { return fs.err } -func (fs *errorFilesystem) RemoveAll(name string) error { return fs.err } -func (fs *errorFilesystem) Rename(oldname, newname string) error { return fs.err } -func (fs *errorFilesystem) Stat(name string) (FileInfo, error) { return nil, fs.err } +func (fs *errorFilesystem) ReadSymlink(_ string) (string, error) { return "", fs.err } +func (fs *errorFilesystem) Remove(_ string) error { return fs.err } +func (fs *errorFilesystem) RemoveAll(_ string) error { return fs.err } +func (fs *errorFilesystem) Rename(_, _ string) error { return fs.err } +func (fs *errorFilesystem) Stat(_ string) (FileInfo, error) { return nil, fs.err } func (fs *errorFilesystem) SymlinksSupported() bool { return false } -func (fs *errorFilesystem) Walk(root string, walkFn WalkFunc) error { return fs.err } -func (fs *errorFilesystem) Unhide(name string) error { return fs.err } -func (fs *errorFilesystem) Hide(name string) error { return fs.err } -func (fs *errorFilesystem) Glob(pattern string) ([]string, error) { return nil, fs.err } -func (fs *errorFilesystem) SyncDir(name string) error { return fs.err } +func (fs *errorFilesystem) Walk(_ string, _ WalkFunc) error { return fs.err } +func (fs *errorFilesystem) Unhide(_ string) error { return fs.err } +func (fs *errorFilesystem) Hide(_ string) error { return fs.err } +func (fs *errorFilesystem) Glob(_ string) ([]string, error) { return nil, fs.err } +func (fs *errorFilesystem) SyncDir(_ string) error { return fs.err } func (fs *errorFilesystem) Roots() ([]string, error) { return nil, fs.err } -func (fs *errorFilesystem) Usage(name string) (Usage, error) { return Usage{}, fs.err } +func (fs *errorFilesystem) Usage(_ string) (Usage, error) { return Usage{}, fs.err } func (fs *errorFilesystem) Type() FilesystemType { return fs.fsType } func (fs *errorFilesystem) URI() string { return fs.uri } func (fs *errorFilesystem) Options() []Option { return nil } -func (fs *errorFilesystem) SameFile(fi1, fi2 FileInfo) bool { return false } -func (fs *errorFilesystem) Watch(path string, ignore Matcher, ctx context.Context, ignorePerms bool) (<-chan Event, <-chan error, error) { +func (fs *errorFilesystem) SameFile(_, _ FileInfo) bool { return false } +func (fs *errorFilesystem) Watch(_ string, _ Matcher, _ context.Context, _ bool) (<-chan Event, <-chan error, error) { return nil, nil, fs.err } -func (fs *errorFilesystem) PlatformData(name string) (protocol.PlatformData, error) { +func (fs *errorFilesystem) PlatformData(_ string) (protocol.PlatformData, error) { return protocol.PlatformData{}, fs.err } diff --git a/lib/fs/fakefs.go b/lib/fs/fakefs.go index a33985cb8..0f542830e 100644 --- a/lib/fs/fakefs.go +++ b/lib/fs/fakefs.go @@ -235,7 +235,7 @@ func (fs *fakeFS) Lchown(name, uid, gid string) error { return nil } -func (fs *fakeFS) Chtimes(name string, atime time.Time, mtime time.Time) error { +func (fs *fakeFS) Chtimes(name string, _ time.Time, mtime time.Time) error { fs.mut.Lock() defer fs.mut.Unlock() fs.counters.Chtimes++ @@ -601,23 +601,23 @@ func (fs *fakeFS) SymlinksSupported() bool { return false } -func (fs *fakeFS) Walk(name string, walkFn WalkFunc) error { +func (fs *fakeFS) Walk(_ string, _ WalkFunc) error { return errors.New("not implemented") } -func (fs *fakeFS) Watch(path string, ignore Matcher, ctx context.Context, ignorePerms bool) (<-chan Event, <-chan error, error) { +func (fs *fakeFS) Watch(_ string, _ Matcher, _ context.Context, _ bool) (<-chan Event, <-chan error, error) { return nil, nil, ErrWatchNotSupported } -func (fs *fakeFS) Hide(name string) error { +func (fs *fakeFS) Hide(_ string) error { return nil } -func (fs *fakeFS) Unhide(name string) error { +func (fs *fakeFS) Unhide(_ string) error { return nil } -func (fs *fakeFS) Glob(pattern string) ([]string, error) { +func (fs *fakeFS) Glob(_ string) ([]string, error) { // gnnh we don't seem to actually require this in practice return nil, errors.New("not implemented") } @@ -626,7 +626,7 @@ func (fs *fakeFS) Roots() ([]string, error) { return []string{"/"}, nil } -func (fs *fakeFS) Usage(name string) (Usage, error) { +func (fs *fakeFS) Usage(_ string) (Usage, error) { return Usage{}, errors.New("not implemented") } diff --git a/lib/fs/mtimefs_test.go b/lib/fs/mtimefs_test.go index 5b547b68c..4431fa2d3 100644 --- a/lib/fs/mtimefs_test.go +++ b/lib/fs/mtimefs_test.go @@ -245,7 +245,7 @@ func (s mapStore) Delete(key string) error { } // failChtimes does nothing, and fails -func failChtimes(name string, mtime, atime time.Time) error { +func failChtimes(_ string, _, _ time.Time) error { return errors.New("no") } diff --git a/lib/model/model.go b/lib/model/model.go index 051b0fe8a..b1c5a59ab 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -1806,7 +1806,7 @@ func (r *requestResponse) Wait() { // Request returns the specified data segment by reading it from local disk. // Implements the protocol.Model interface. -func (m *model) Request(deviceID protocol.DeviceID, folder, name string, blockNo, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (out protocol.RequestResponse, err error) { +func (m *model) Request(deviceID protocol.DeviceID, folder, name string, _, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (out protocol.RequestResponse, err error) { if size < 0 || offset < 0 { return nil, protocol.ErrInvalid } diff --git a/lib/nat/service.go b/lib/nat/service.go index 5e2f1c704..17b0d40ea 100644 --- a/lib/nat/service.go +++ b/lib/nat/service.go @@ -45,7 +45,7 @@ func NewService(id protocol.DeviceID, cfg config.Wrapper) *Service { return s } -func (s *Service) CommitConfiguration(from, to config.Configuration) bool { +func (s *Service) CommitConfiguration(_, to config.Configuration) bool { s.mut.Lock() if !s.enabled && to.Options.NATEnabled { l.Debugln("Starting NAT service") diff --git a/lib/pmp/pmp.go b/lib/pmp/pmp.go index 7530eb046..e1cd29791 100644 --- a/lib/pmp/pmp.go +++ b/lib/pmp/pmp.go @@ -97,7 +97,7 @@ func (w *wrapper) GetLocalIPAddress() net.IP { return w.localIP } -func (w *wrapper) AddPortMapping(ctx context.Context, protocol nat.Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error) { +func (w *wrapper) AddPortMapping(ctx context.Context, protocol nat.Protocol, internalPort, externalPort int, _ string, duration time.Duration) (int, error) { // NAT-PMP says that if duration is 0, the mapping is actually removed // Swap the zero with the renewal value, which should make the lease for the // exact amount of time between the calls. diff --git a/lib/protocol/benchmark_test.go b/lib/protocol/benchmark_test.go index 1b3bd304e..11647a4ee 100644 --- a/lib/protocol/benchmark_test.go +++ b/lib/protocol/benchmark_test.go @@ -167,15 +167,15 @@ func negotiateTLS(cert tls.Certificate, conn0, conn1 net.Conn) (net.Conn, net.Co type fakeModel struct{} -func (m *fakeModel) Index(deviceID DeviceID, folder string, files []FileInfo) error { +func (m *fakeModel) Index(_ DeviceID, _ string, _ []FileInfo) error { return nil } -func (m *fakeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) error { +func (m *fakeModel) IndexUpdate(_ DeviceID, _ string, _ []FileInfo) error { return nil } -func (m *fakeModel) Request(deviceID DeviceID, folder, name string, blockNo, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) { +func (m *fakeModel) Request(_ DeviceID, _, _ string, _, size int32, offset int64, _ []byte, _ uint32, _ bool) (RequestResponse, error) { // We write the offset to the end of the buffer, so the receiver // can verify that it did in fact get some data back over the // connection. @@ -184,13 +184,13 @@ func (m *fakeModel) Request(deviceID DeviceID, folder, name string, blockNo, siz return &fakeRequestResponse{buf}, nil } -func (m *fakeModel) ClusterConfig(deviceID DeviceID, config ClusterConfig) error { +func (m *fakeModel) ClusterConfig(_ DeviceID, _ ClusterConfig) error { return nil } func (m *fakeModel) Closed(DeviceID, error) { } -func (m *fakeModel) DownloadProgress(deviceID DeviceID, folder string, updates []FileDownloadProgressUpdate) error { +func (m *fakeModel) DownloadProgress(_ DeviceID, _ string, _ []FileDownloadProgressUpdate) error { return nil } diff --git a/lib/protocol/common_test.go b/lib/protocol/common_test.go index 6e5c7f02c..9ca9cf985 100644 --- a/lib/protocol/common_test.go +++ b/lib/protocol/common_test.go @@ -32,11 +32,11 @@ func (t *TestModel) Index(deviceID DeviceID, folder string, files []FileInfo) er return nil } -func (t *TestModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) error { +func (t *TestModel) IndexUpdate(_ DeviceID, _ string, _ []FileInfo) error { return nil } -func (t *TestModel) Request(deviceID DeviceID, folder, name string, blockNo, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) { +func (t *TestModel) Request(_ DeviceID, folder, name string, _, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) { t.folder = folder t.name = name t.offset = offset diff --git a/lib/relay/protocol/packets_xdr.go b/lib/relay/protocol/packets_xdr.go index dcbe013c4..924f68414 100644 --- a/lib/relay/protocol/packets_xdr.go +++ b/lib/relay/protocol/packets_xdr.go @@ -89,15 +89,15 @@ func (o Ping) MustMarshalXDR() []byte { return nil } -func (o Ping) MarshalXDRInto(m *xdr.Marshaller) error { +func (o Ping) MarshalXDRInto(_ *xdr.Marshaller) error { return nil } -func (o *Ping) UnmarshalXDR(bs []byte) error { +func (o *Ping) UnmarshalXDR(_ []byte) error { return nil } -func (o *Ping) UnmarshalXDRFrom(u *xdr.Unmarshaller) error { +func (o *Ping) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { return nil } @@ -123,15 +123,15 @@ func (o Pong) MustMarshalXDR() []byte { return nil } -func (o Pong) MarshalXDRInto(m *xdr.Marshaller) error { +func (o Pong) MarshalXDRInto(_ *xdr.Marshaller) error { return nil } -func (o *Pong) UnmarshalXDR(bs []byte) error { +func (o *Pong) UnmarshalXDR(_ []byte) error { return nil } -func (o *Pong) UnmarshalXDRFrom(u *xdr.Unmarshaller) error { +func (o *Pong) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { return nil } @@ -157,15 +157,15 @@ func (o JoinRelayRequest) MustMarshalXDR() []byte { return nil } -func (o JoinRelayRequest) MarshalXDRInto(m *xdr.Marshaller) error { +func (o JoinRelayRequest) MarshalXDRInto(_ *xdr.Marshaller) error { return nil } -func (o *JoinRelayRequest) UnmarshalXDR(bs []byte) error { +func (o *JoinRelayRequest) UnmarshalXDR(_ []byte) error { return nil } -func (o *JoinRelayRequest) UnmarshalXDRFrom(u *xdr.Unmarshaller) error { +func (o *JoinRelayRequest) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { return nil } @@ -191,15 +191,15 @@ func (o RelayFull) MustMarshalXDR() []byte { return nil } -func (o RelayFull) MarshalXDRInto(m *xdr.Marshaller) error { +func (o RelayFull) MarshalXDRInto(_ *xdr.Marshaller) error { return nil } -func (o *RelayFull) UnmarshalXDR(bs []byte) error { +func (o *RelayFull) UnmarshalXDR(_ []byte) error { return nil } -func (o *RelayFull) UnmarshalXDRFrom(u *xdr.Unmarshaller) error { +func (o *RelayFull) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error { return nil } diff --git a/lib/scanner/blocks.go b/lib/scanner/blocks.go index d1a9ae0a5..5009cde7e 100644 --- a/lib/scanner/blocks.go +++ b/lib/scanner/blocks.go @@ -139,4 +139,4 @@ func (noopHash) Write([]byte) (int, error) { return 0, nil } type noopCounter struct{} -func (c *noopCounter) Update(bytes int64) {} +func (c *noopCounter) Update(_ int64) {} diff --git a/lib/scanner/virtualfs_test.go b/lib/scanner/virtualfs_test.go index 5eff7c11e..09e0b2c56 100644 --- a/lib/scanner/virtualfs_test.go +++ b/lib/scanner/virtualfs_test.go @@ -55,7 +55,7 @@ func (i infiniteFS) Open(name string) (fs.File, error) { return &fakeFile{name, i.filesize, 0}, nil } -func (i infiniteFS) PlatformData(name string) (protocol.PlatformData, error) { +func (i infiniteFS) PlatformData(_ string) (protocol.PlatformData, error) { return protocol.PlatformData{}, nil } @@ -105,7 +105,7 @@ func (s singleFileFS) Options() []fs.Option { return nil } -func (s singleFileFS) PlatformData(name string) (protocol.PlatformData, error) { +func (s singleFileFS) PlatformData(_ string) (protocol.PlatformData, error) { return protocol.PlatformData{}, nil } @@ -156,7 +156,7 @@ func (f *fakeFile) Stat() (fs.FileInfo, error) { func (f *fakeFile) Write([]byte) (int, error) { return 0, errNotSupp } func (f *fakeFile) WriteAt([]byte, int64) (int, error) { return 0, errNotSupp } func (f *fakeFile) Close() error { return nil } -func (f *fakeFile) Truncate(size int64) error { return errNotSupp } +func (f *fakeFile) Truncate(_ int64) error { return errNotSupp } func (f *fakeFile) ReadAt([]byte, int64) (int, error) { return 0, errNotSupp } func (f *fakeFile) Seek(int64, int) (int64, error) { return 0, errNotSupp } func (f *fakeFile) Sync() error { return nil } diff --git a/lib/scanner/walk.go b/lib/scanner/walk.go index 71618a15e..b25bec475 100644 --- a/lib/scanner/walk.go +++ b/lib/scanner/walk.go @@ -662,7 +662,7 @@ func (c *byteCounter) Close() { type noCurrentFiler struct{} -func (noCurrentFiler) CurrentFile(name string) (protocol.FileInfo, bool) { +func (noCurrentFiler) CurrentFile(_ string) (protocol.FileInfo, bool) { return protocol.FileInfo{}, false } diff --git a/lib/scanner/walk_test.go b/lib/scanner/walk_test.go index a83664dd6..d9dc9102d 100644 --- a/lib/scanner/walk_test.go +++ b/lib/scanner/walk_test.go @@ -310,7 +310,7 @@ func TestNormalizationDarwinCaseFS(t *testing.T) { } } -func TestIssue1507(t *testing.T) { +func TestIssue1507(_ *testing.T) { w := &walker{} w.Matcher = ignore.New(w.Filesystem) h := make(chan protocol.FileInfo, 100) diff --git a/lib/stun/filter.go b/lib/stun/filter.go index 8be3bd4de..863ab10a4 100644 --- a/lib/stun/filter.go +++ b/lib/stun/filter.go @@ -23,7 +23,7 @@ type stunFilter struct { mut sync.Mutex } -func (f *stunFilter) Outgoing(out []byte, addr net.Addr) { +func (f *stunFilter) Outgoing(out []byte, _ net.Addr) { if !f.isStunPayload(out) { panic("not a stun payload") } @@ -33,7 +33,7 @@ func (f *stunFilter) Outgoing(out []byte, addr net.Addr) { f.mut.Unlock() } -func (f *stunFilter) ClaimIncoming(in []byte, addr net.Addr) bool { +func (f *stunFilter) ClaimIncoming(in []byte, _ net.Addr) bool { if f.isStunPayload(in) { f.mut.Lock() _, ok := f.ids[string(in[8:20])] diff --git a/lib/testutils/testutils.go b/lib/testutils/testutils.go index e2de556ff..ffdf2bfd9 100644 --- a/lib/testutils/testutils.go +++ b/lib/testutils/testutils.go @@ -25,12 +25,12 @@ func NewBlockingRW() *BlockingRW { closeOnce: sync.Once{}, } } -func (rw *BlockingRW) Read(p []byte) (int, error) { +func (rw *BlockingRW) Read(_ []byte) (int, error) { <-rw.c return 0, ErrClosed } -func (rw *BlockingRW) Write(p []byte) (int, error) { +func (rw *BlockingRW) Write(_ []byte) (int, error) { <-rw.c return 0, ErrClosed } diff --git a/lib/upnp/upnp.go b/lib/upnp/upnp.go index 8b2c8a17b..56239bd27 100644 --- a/lib/upnp/upnp.go +++ b/lib/upnp/upnp.go @@ -85,7 +85,7 @@ func (e *UnsupportedDeviceTypeError) Error() string { // Discover discovers UPnP InternetGatewayDevices. // The order in which the devices appear in the results list is not deterministic. -func Discover(ctx context.Context, renewal, timeout time.Duration) []nat.Device { +func Discover(ctx context.Context, _, timeout time.Duration) []nat.Device { var results []nat.Device interfaces, err := net.Interfaces() diff --git a/lib/util/semaphore_test.go b/lib/util/semaphore_test.go index 99b583887..080be26e5 100644 --- a/lib/util/semaphore_test.go +++ b/lib/util/semaphore_test.go @@ -8,7 +8,7 @@ package util import "testing" -func TestZeroByteSempahore(t *testing.T) { +func TestZeroByteSempahore(_ *testing.T) { // A semaphore with zero capacity is just a no-op. s := NewSemaphore(0) diff --git a/lib/versioner/external.go b/lib/versioner/external.go index 2319077e4..2365af99b 100644 --- a/lib/versioner/external.go +++ b/lib/versioner/external.go @@ -117,7 +117,7 @@ func (v external) GetVersions() (map[string][]FileVersion, error) { return nil, ErrRestorationNotSupported } -func (v external) Restore(filePath string, versionTime time.Time) error { +func (v external) Restore(_ string, _ time.Time) error { return ErrRestorationNotSupported } diff --git a/lib/watchaggregator/aggregator.go b/lib/watchaggregator/aggregator.go index 322aa502e..a21b5462b 100644 --- a/lib/watchaggregator/aggregator.go +++ b/lib/watchaggregator/aggregator.go @@ -421,7 +421,7 @@ func (a *aggregator) String() string { return fmt.Sprintf("aggregator/%s:", a.folderCfg.Description()) } -func (a *aggregator) CommitConfiguration(from, to config.Configuration) bool { +func (a *aggregator) CommitConfiguration(_, to config.Configuration) bool { for _, folderCfg := range to.Folders { if folderCfg.ID == a.folderID { select { diff --git a/meta/metalint_test.go b/meta/metalint_test.go index 6113a5836..0c0407373 100644 --- a/meta/metalint_test.go +++ b/meta/metalint_test.go @@ -70,7 +70,7 @@ func isGometalinterInstalled() bool { return true } -func gometalinter(t *testing.T, dirs []string, excludes ...string) bool { +func gometalinter(_ *testing.T, dirs []string, excludes ...string) bool { params := []string{"--disable-all", "--concurrency=2", "--deadline=300s"} for _, linter := range fastLinters {