Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes errcheck errors pointed by golangci-lint #2782

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arbnode/delayed.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ func (b *DelayedBridge) parseMessage(ctx context.Context, ethLog types.Log) (*bi
if err != nil {
return nil, nil, err
}
// nolint:errcheck
return parsedLog.MessageNum, args["messageData"].([]byte), nil
default:
return nil, nil, errors.New("unexpected log type")
Expand Down
1 change: 1 addition & 0 deletions arbnode/sequencer_inbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (m *SequencerInboxBatch) getSequencerData(ctx context.Context, client *ethc
if err != nil {
return nil, err
}
// nolint:errcheck
return args["data"].([]byte), nil
case batchDataSeparateEvent:
var numberAsHash common.Hash
Expand Down
2 changes: 2 additions & 0 deletions broadcastclient/broadcastclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func TestInvalidSignature(t *testing.T) {
badPrivateKey, err := crypto.GenerateKey()
Require(t, err)
badPublicKey := badPrivateKey.Public()
// nolint:errcheck
badSequencerAddr := crypto.PubkeyToAddress(*badPublicKey.(*ecdsa.PublicKey))
config := DefaultTestConfig

Expand Down Expand Up @@ -202,6 +203,7 @@ func (ts *dummyTransactionStreamer) AddBroadcastMessages(feedMessages []*m.Broad
}

func newTestBroadcastClient(config Config, listenerAddress net.Addr, chainId uint64, currentMessageCount arbutil.MessageIndex, txStreamer TransactionStreamerInterface, confirmedSequenceNumberListener chan arbutil.MessageIndex, feedErrChan chan error, validAddr *common.Address) (*BroadcastClient, error) {
// nolint:errcheck
port := listenerAddress.(*net.TCPAddr).Port
var av contracts.AddressVerifierInterface
if validAddr != nil {
Expand Down
4 changes: 3 additions & 1 deletion broadcaster/backlog/backlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ func newBacklogSegment() *backlogSegment {
func IsBacklogSegmentNil(segment BacklogSegment) bool {
if segment == nil {
return true
} else if segment.(*backlogSegment) == nil {
}
// nolint:errcheck
if segment.(*backlogSegment) == nil {
return true
}
return false
Expand Down
1 change: 1 addition & 0 deletions cmd/genericconf/filehandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func readLogMessagesFromJSONFile(t *testing.T, path string) ([]string, error) {
if !ok {
testhelpers.FailImpl(t, "Incorrect record, msg key is missing", "record", record)
}
// nolint:errcheck
messages = append(messages, msg.(string))
}
if errors.Is(err, io.EOF) {
Expand Down
2 changes: 2 additions & 0 deletions das/reader_aggregator_strategies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ func TestDAS_SimpleExploreExploit(t *testing.T) {
}

for i := 0; i < len(was) && doMatch; i++ {
// nolint:errcheck
if expected[i].(*dummyReader).int != was[i].(*dummyReader).int {
// nolint:errcheck
Fail(t, fmt.Sprintf("expected %d, was %d", expected[i].(*dummyReader).int, was[i].(*dummyReader).int))
}
}
Expand Down
2 changes: 2 additions & 0 deletions execution/nodeInterface/NodeInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ func (n NodeInterface) GasEstimateL1Component(
if err := args.CallDefaults(randomGas, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil {
return 0, nil, nil, err
}
// nolint:errcheck
msg := args.ToMessage(evm.Context.BaseFee, randomGas, n.header, evm.StateDB.(*state.StateDB), core.MessageEthcallMode)

pricing := c.State.L1PricingState()
Expand Down Expand Up @@ -581,6 +582,7 @@ func (n NodeInterface) GasEstimateComponents(
if err := args.CallDefaults(gasCap, evm.Context.BaseFee, evm.ChainConfig().ChainID); err != nil {
return 0, 0, nil, nil, err
}
// nolint:errcheck
msg := args.ToMessage(evm.Context.BaseFee, gasCap, n.header, evm.StateDB.(*state.StateDB), core.MessageGasEstimationMode)
brotliCompressionLevel, err := c.State.BrotliCompressionLevel()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions linters/koanf/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func checkFlagDefs(pass *analysis.Pass, f *ast.FuncDecl, cnt map[string]int) Res
if !ok {
continue
}
// nolint:errcheck
handleSelector(pass, callE.Args[1].(*ast.SelectorExpr), -1, cnt)
if normSL := normalizeTag(sl); !strings.EqualFold(normSL, s) {
res.Errors = append(res.Errors, koanfError{
Expand Down
2 changes: 2 additions & 0 deletions system_tests/seq_coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func TestRedisSeqCoordinatorPriorities(t *testing.T) {

nodeForwardTarget := func(nodeNum int) int {
execNode := testNodes[nodeNum].ExecNode
// nolint:errcheck
fwTarget := execNode.TxPublisher.(*gethexec.TxPreChecker).TransactionPublisher.(*gethexec.Sequencer).ForwardTarget()
if fwTarget == "" {
return -1
Expand Down Expand Up @@ -323,6 +324,7 @@ func testCoordinatorMessageSync(t *testing.T, successCase bool) {
// nodeB doesn't sequence transactions, but adds messages related to them to its output feed.
// nodeBOutputFeedReader reads those messages from this feed and processes them.
// nodeBOutputFeedReader doesn't read messages from L1 since none of the nodes posts to L1.
// nolint:errcheck
nodeBPort := testClientB.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port
nodeConfigNodeBOutputFeedReader := arbnode.ConfigDefaultL1NonSequencerTest()
nodeConfigNodeBOutputFeedReader.Feed.Input = *newBroadcastClientConfigTest(nodeBPort)
Expand Down
1 change: 1 addition & 0 deletions system_tests/seq_reject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func TestSequencerRejection(t *testing.T) {

builder := NewNodeBuilder(ctx).DefaultConfig(t, false)
builder.takeOwnership = false
// nolint:errcheck
port := builderSeq.L2.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port
builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port)
cleanup := builder.Build(t)
Expand Down
6 changes: 6 additions & 0 deletions system_tests/seqfeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func TestSequencerFeed(t *testing.T) {
defer cleanupSeq()
seqInfo, seqNode, seqClient := builderSeq.L2Info, builderSeq.L2.ConsensusNode, builderSeq.L2.Client

// nolint:errcheck
port := seqNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port
builder := NewNodeBuilder(ctx).DefaultConfig(t, false)
builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port)
Expand Down Expand Up @@ -107,6 +108,7 @@ func TestRelayedSequencerFeed(t *testing.T) {
Require(t, err)

config := relay.ConfigDefault
// nolint:errcheck
port := seqNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port
config.Node.Feed.Input = *newBroadcastClientConfigTest(port)
config.Node.Feed.Output = *newBroadcasterConfigTest()
Expand All @@ -119,6 +121,7 @@ func TestRelayedSequencerFeed(t *testing.T) {
Require(t, err)
defer currentRelay.StopAndWait()

// nolint:errcheck
port = currentRelay.GetListenerAddr().(*net.TCPAddr).Port
builder := NewNodeBuilder(ctx).DefaultConfig(t, false)
builder.nodeConfig.Feed.Input = *newBroadcastClientConfigTest(port)
Expand Down Expand Up @@ -219,6 +222,7 @@ func testLyingSequencer(t *testing.T, dasModeStr string) {
defer cleanupC()
l2clientC, nodeC := testClientC.Client, testClientC.ConsensusNode

// nolint:errcheck
port := nodeC.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port

// The client node, connects to lying sequencer's feed
Expand Down Expand Up @@ -361,6 +365,7 @@ func testBlockHashComparison(t *testing.T, blockHash *common.Hash, mustMismatch
}
defer wsBroadcastServer.StopAndWait()

// nolint:errcheck
port := wsBroadcastServer.ListenerAddr().(*net.TCPAddr).Port

builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
Expand Down Expand Up @@ -468,6 +473,7 @@ func TestPopulateFeedBacklog(t *testing.T) {

// Creates a sink node that will read from the output feed of the previous node.
nodeConfigSink := builder.nodeConfig
// nolint:errcheck
port := builder.L2.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port
nodeConfigSink.Feed.Input = *newBroadcastClientConfigTest(port)
testClientSink, cleanupSink := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: nodeConfigSink})
Expand Down
2 changes: 2 additions & 0 deletions util/containers/syncmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func (m *SyncMap[K, V]) Load(key K) (V, bool) {
var empty V
return empty, false
}
// nolint:errcheck
return val.(V), true
}

Expand All @@ -27,6 +28,7 @@ func (m *SyncMap[K, V]) Delete(key K) {
func (m *SyncMap[K, V]) Keys() []K {
s := make([]K, 0)
m.internal.Range(func(k, v interface{}) bool {
// nolint:errcheck
s = append(s, k.(K))
return true
})
Expand Down
2 changes: 2 additions & 0 deletions util/testhelpers/port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ func TestFreeTCPPortListener(t *testing.T) {
if err != nil {
t.Fatal(err)
}
// nolint:errcheck
if aListener.Addr().(*net.TCPAddr).Port == bListener.Addr().(*net.TCPAddr).Port {
t.Errorf("FreeTCPPortListener() got same port: %v, %v", aListener, bListener)
}
// nolint:errcheck
if aListener.Addr().(*net.TCPAddr).Port == 0 || bListener.Addr().(*net.TCPAddr).Port == 0 {
t.Errorf("FreeTCPPortListener() got port 0")
}
Expand Down
Loading