Skip to content

Commit

Permalink
go: unused-parameter lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Feb 14, 2024
1 parent 90b5555 commit 43ebafd
Show file tree
Hide file tree
Showing 37 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion go/beacon/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func handlerGetBaseEpoch(
Server: srv,
FullMethod: methodGetBaseEpoch.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(Backend).GetBaseEpoch(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand Down
2 changes: 1 addition & 1 deletion go/common/crash/crash.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func ListRegisteredCrashPoints() []string {
// ListRegisteredCrashPoints lists the registered crash points for a Crasher instance.
func (c *Crasher) ListRegisteredCrashPoints() []string {
var crashPointIDs []string
c.CrashPointConfig.Range(func(k, v interface{}) bool {
c.CrashPointConfig.Range(func(k, _ interface{}) bool {
crashPointIDs = append(crashPointIDs, k.(string))
return true
})
Expand Down
6 changes: 3 additions & 3 deletions go/common/crypto/signature/signers/remote/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func handlerPublicKeys(
Server: srv,
FullMethod: methodPublicKeys.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(_ context.Context, _ interface{}) (interface{}, error) {
return srv.(Backend).PublicKeys()
}
return interceptor(ctx, nil, info, handler)
Expand All @@ -148,7 +148,7 @@ func handlerSign(
Server: srv,
FullMethod: methodSign.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(_ context.Context, req interface{}) (interface{}, error) {
return srv.(Backend).Sign(req.(*SignRequest))
}
return interceptor(ctx, &req, info, handler)
Expand All @@ -171,7 +171,7 @@ func handlerProve(
Server: srv,
FullMethod: methodProve.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(_ context.Context, req interface{}) (interface{}, error) {
return srv.(Backend).Prove(req.(*ProveRequest))
}
return interceptor(ctx, &req, info, handler)
Expand Down
4 changes: 2 additions & 2 deletions go/common/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,14 @@ func NewServer(config *ServerConfig) (*Server, error) {
if config.Identity != nil && config.Identity.TLSCertificate != nil {
tlsConfig := &tls.Config{
ClientAuth: clientAuthType,
VerifyPeerCertificate: func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
VerifyPeerCertificate: func(rawCerts [][]byte, _ [][]*x509.Certificate) error {
return cmnTLS.VerifyCertificate(rawCerts, cmnTLS.VerifyOptions{
CommonName: config.ClientCommonName,
AllowUnknownKeys: true,
AllowNoCertificate: true,
})
},
GetCertificate: func(ch *tls.ClientHelloInfo) (*tls.Certificate, error) {
GetCertificate: func(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {
return config.Identity.TLSCertificate, nil
},
}
Expand Down
4 changes: 2 additions & 2 deletions go/common/grpc/testing/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
serviceName = cmnGrpc.NewServiceName("PingService")
// MethodPing is the Ping method.
MethodPing = serviceName.NewMethod("Ping", PingQuery{}).
WithNamespaceExtractor(func(ctx context.Context, req interface{}) (common.Namespace, error) {
WithNamespaceExtractor(func(_ context.Context, req interface{}) (common.Namespace, error) {
r, ok := req.(*PingQuery)
if !ok {
return common.Namespace{}, errInvalidRequestType
Expand All @@ -42,7 +42,7 @@ var (

// MethodWatchPings is the WatchPings method.
MethodWatchPings = serviceName.NewMethod("WatchPings", PingQuery{}).
WithNamespaceExtractor(func(ctx context.Context, req interface{}) (common.Namespace, error) {
WithNamespaceExtractor(func(_ context.Context, req interface{}) (common.Namespace, error) {
r, ok := req.(*PingQuery)
if !ok {
return common.Namespace{}, errInvalidRequestType
Expand Down
2 changes: 1 addition & 1 deletion go/common/grpc/wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func multiPingUnaryHandler(
Server: srv,
FullMethod: "/MultiPingService/Ping",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(MultiPingServer).Ping(ctx)
}
return interceptor(ctx, pq, info, handler)
Expand Down
10 changes: 5 additions & 5 deletions go/common/scheduling/fixed_rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestFixedRateScheduler(t *testing.T) {
t.Run("No tasks", func(t *testing.T) {
t.Run("No tasks", func(_ *testing.T) {
scheduler := NewFixedRateScheduler(time.Millisecond, time.Millisecond)
scheduler.Start()
time.Sleep(5 * time.Millisecond)
Expand All @@ -20,8 +20,8 @@ func TestFixedRateScheduler(t *testing.T) {
require := require.New(t)

n1, n2 := 0, 0
t1 := func(ctx context.Context) error { n1++; return nil }
t2 := func(ctx context.Context) error { n2++; return nil }
t1 := func(_ context.Context) error { n1++; return nil }
t2 := func(_ context.Context) error { n2++; return nil }

scheduler := NewFixedRateScheduler(time.Millisecond, time.Millisecond)
scheduler.AddTask("t1", t1)
Expand All @@ -40,8 +40,8 @@ func TestFixedRateScheduler(t *testing.T) {
require := require.New(t)

n1, n2 := 0, 0
t1 := func(ctx context.Context) error { n1++; return nil }
t2 := func(ctx context.Context) error { n2++; return nil }
t1 := func(_ context.Context) error { n1++; return nil }
t2 := func(_ context.Context) error { n2++; return nil }

scheduler := NewFixedRateScheduler(time.Millisecond, time.Millisecond)
scheduler.AddTask("t1", t1)
Expand Down
2 changes: 1 addition & 1 deletion go/common/sgx/pcs/quote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func FuzzQuoteUnmarshal(f *testing.F) {
f.Add(raw2)

// Fuzzing.
f.Fuzz(func(t *testing.T, data []byte) {
f.Fuzz(func(_ *testing.T, data []byte) {
var quote Quote
_ = quote.UnmarshalBinary(data)
})
Expand Down
2 changes: 1 addition & 1 deletion go/common/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestOne(t *testing.T) {
noopFn := func(ctx context.Context) {}
noopFn := func(_ context.Context) {}
blockFn := func(ctx context.Context) {
<-ctx.Done()
}
Expand Down
10 changes: 5 additions & 5 deletions go/consensus/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func handlerGetUnconfirmedTransactions(
Server: srv,
FullMethod: methodGetUnconfirmedTransactions.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(ClientBackend).GetUnconfirmedTransactions(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand Down Expand Up @@ -522,7 +522,7 @@ func handlerGetGenesisDocument(
Server: srv,
FullMethod: methodGetGenesisDocument.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(ClientBackend).GetGenesisDocument(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand All @@ -541,7 +541,7 @@ func handlerGetChainContext(
Server: srv,
FullMethod: methodGetChainContext.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(ClientBackend).GetChainContext(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand All @@ -560,7 +560,7 @@ func handlerGetStatus(
Server: srv,
FullMethod: methodGetStatus.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(ClientBackend).GetStatus(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand All @@ -579,7 +579,7 @@ func handlerGetNextBlockState(
Server: srv,
FullMethod: methodGetNextBlockState.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(ClientBackend).GetNextBlockState(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand Down
2 changes: 1 addition & 1 deletion go/consensus/cometbft/abci/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ func newApplicationState(ctx context.Context, upgrader upgrade.Backend, cfg *App
Name: "consensus",
CheckInterval: cfg.CheckpointerCheckInterval,
RootsPerVersion: 1,
GetParameters: func(ctx context.Context) (*checkpoint.CreationParameters, error) {
GetParameters: func(_ context.Context) (*checkpoint.CreationParameters, error) {
params := s.ConsensusParameters()
return &checkpoint.CreationParameters{
Interval: params.StateCheckpointInterval,
Expand Down
2 changes: 1 addition & 1 deletion go/consensus/cometbft/full/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ func (t *fullService) lazyInit() error { // nolint: gocyclo
t.failMonitor = newFailMonitor(t.ctx, t.Logger, t.node.ConsensusState().Wait)

// Register a halt hook that handles upgrades gracefully.
t.RegisterHaltHook(func(ctx context.Context, blockHeight int64, epoch beaconAPI.EpochTime, err error) {
t.RegisterHaltHook(func(_ context.Context, _ int64, _ beaconAPI.EpochTime, err error) {
if !errors.Is(err, upgradeAPI.ErrStopForUpgrade) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion go/consensus/p2p/light/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (

func init() {
peermgmt.RegisterNodeHandler(&peermgmt.NodeHandlerBundle{
ProtocolsFn: func(n *node.Node, chainContext string) []core.ProtocolID {
ProtocolsFn: func(_ *node.Node, chainContext string) []core.ProtocolID {
return []core.ProtocolID{ProtocolID(chainContext)}
},
})
Expand Down
10 changes: 5 additions & 5 deletions go/control/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func handlerWaitSync(
Server: srv,
FullMethod: methodWaitSync.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return nil, srv.(NodeController).WaitSync(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand All @@ -127,7 +127,7 @@ func handlerIsSynced(
Server: srv,
FullMethod: methodIsSynced.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(NodeController).IsSynced(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand All @@ -146,7 +146,7 @@ func handlerWaitReady(
Server: srv,
FullMethod: methodWaitReady.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return nil, srv.(NodeController).WaitReady(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand All @@ -165,7 +165,7 @@ func handlerIsReady(
Server: srv,
FullMethod: methodIsSynced.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(NodeController).IsReady(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand Down Expand Up @@ -230,7 +230,7 @@ func handlerGetStatus(
Server: srv,
FullMethod: methodGetStatus.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(NodeController).GetStatus(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand Down
2 changes: 1 addition & 1 deletion go/ias/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func handlerGetSPIDInfo(
Server: srv,
FullMethod: methodGetSPIDInfo.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(Endpoint).GetSPIDInfo(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand Down
2 changes: 1 addition & 1 deletion go/ias/proxy/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func New(identity *identity.Identity, addresses []string) ([]api.Endpoint, error
creds, err := cmnGrpc.NewClientCreds(&cmnGrpc.ClientOptions{
ServerPubKeys: map[signature.PublicKey]bool{pk: true},
CommonName: proxy.CommonName,
GetClientCertificate: func(cri *tls.CertificateRequestInfo) (*tls.Certificate, error) {
GetClientCertificate: func(_ *tls.CertificateRequestInfo) (*tls.Certificate, error) {
return identity.TLSCertificate, nil
},
})
Expand Down
2 changes: 1 addition & 1 deletion go/oasis-test-runner/oasis/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func GenerateDeterministicNodeKeys(dir *env.Dir, rawSeed string, roles []signatu
}

var dirStr string
factoryCtor := func(args interface{}, roles ...signature.SignerRole) (signature.SignerFactory, error) {
factoryCtor := func(_ interface{}, _ ...signature.SignerRole) (signature.SignerFactory, error) {
return memorySigner.NewFactory(), nil
}
if dir != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,17 @@ func (sc *governanceConsensusUpgradeImpl) Run(ctx context.Context, childEnv *env
var group sync.WaitGroup
errCh := make(chan error, len(sc.Net.Nodes()))
if !sc.shouldCancelUpgrade {
for i, nd := range sc.Net.Nodes() {
for _, nd := range sc.Net.Nodes() {
group.Add(1)
go func(i int, nd *oasis.Node) {
go func(nd *oasis.Node) {
defer group.Done()
sc.Logger.Info("waiting for node to exit", "node", nd.Name)
<-nd.Exit()
sc.Logger.Info("restarting node", "node", nd.Name)
if err = nd.Restart(ctx); err != nil {
errCh <- err
}
}(i, nd)
}(nd)
}
}

Expand Down
2 changes: 1 addition & 1 deletion go/oasis-test-runner/scenario/e2e/runtime/test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (cli *TestClient) submit(ctx context.Context, req interface{}, rng rand.Sou
func NewTestClient() *TestClient {
return &TestClient{
seed: "seed",
scenario: func(submit func(req interface{}) error) error { return nil },
scenario: func(_ func(req interface{}) error) error { return nil },
}
}

Expand Down
2 changes: 1 addition & 1 deletion go/p2p/peermgmt/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *DiscoveryTestSuite) TestAdvertise() {
return
}
case <-ctx.Done():
require.Equal(s.T(), expected, s.advertiseCount())
require.Equal(t, expected, s.advertiseCount())
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion go/p2p/peermgmt/peermgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s *PeerManagerTestSuite) SetupTest() {
// Let every peer support few protocols.
for i := 0; i < n; i++ {
for j := i; j < n; j++ {
s.peers[i].SetStreamHandler(s.protocols[j], func(stream network.Stream) {})
s.peers[i].SetStreamHandler(s.protocols[j], func(_ network.Stream) {})
}
}

Expand Down
2 changes: 1 addition & 1 deletion go/p2p/protocol/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestProtocolID(t *testing.T) {

registry = newProtocolRegistry()

t.Run("ValidateProtocolID", func(t *testing.T) {
t.Run("ValidateProtocolID", func(_ *testing.T) {
ValidateProtocolID("protocol-1")
ValidateProtocolID("protocol-2")
})
Expand Down
4 changes: 2 additions & 2 deletions go/roothash/api/commitment/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,15 +915,15 @@ func TestVerify(t *testing.T) {
require.NoError(t, err)

invalidMsgErr := fmt.Errorf("all messages are invalid")
alwaysInvalidValidator := func(msgs []message.Message) error {
alwaysInvalidValidator := func(_ []message.Message) error {
return invalidMsgErr
}

err = VerifyExecutorCommitment(ctx, lastBlock, rtTEE, committee.ValidFor, ec, alwaysInvalidValidator, nil)
require.ErrorIs(t, err, invalidMsgErr)

// And they are.
alwaysValidValidator := func(msgs []message.Message) error {
alwaysValidValidator := func(_ []message.Message) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion go/runtime/history/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (p *nonePruner) Prune(context.Context, uint64) error {

// NewNonePruner creates a new pruner that never prunes anything.
func NewNonePruner() PrunerFactory {
return func(db *DB) (Pruner, error) {
return func(_ *DB) (Pruner, error) {
return &nonePruner{}, nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions go/runtime/host/sandbox/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ func New(cfg Config) (host.Provisioner, error) {
}
// Use a default GetSandboxConfig if none was provided.
if cfg.GetSandboxConfig == nil {
cfg.GetSandboxConfig = func(hostCfg host.Config, socketPath, runtimeDir string) (process.Config, error) {
cfg.GetSandboxConfig = func(hostCfg host.Config, socketPath, _ string) (process.Config, error) {
logWrapper := host.NewRuntimeLogWrapper(
cfg.Logger,
"runtime_id", hostCfg.Bundle.Manifest.ID,
Expand All @@ -639,7 +639,7 @@ func New(cfg Config) (host.Provisioner, error) {
}
// Use a default HostInitializer if none was provided.
if cfg.HostInitializer == nil {
cfg.HostInitializer = func(ctx context.Context, hp *HostInitializerParams) (*host.StartedEvent, error) {
cfg.HostInitializer = func(_ context.Context, hp *HostInitializerParams) (*host.StartedEvent, error) {
return &host.StartedEvent{
Version: hp.Version,
}, nil
Expand Down
2 changes: 1 addition & 1 deletion go/sentry/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func handlerGetAddresses(
Server: srv,
FullMethod: methodGetAddresses.FullName(),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, _ interface{}) (interface{}, error) {
return srv.(Backend).GetAddresses(ctx)
}
return interceptor(ctx, nil, info, handler)
Expand Down
Loading

0 comments on commit 43ebafd

Please sign in to comment.