Skip to content

Add a Linter to Detect Defer Calls in For Loop#4616

Merged
rauljordan merged 4 commits intomasterfrom
raul/linter-for-loop-defer
Apr 10, 2026
Merged

Add a Linter to Detect Defer Calls in For Loop#4616
rauljordan merged 4 commits intomasterfrom
raul/linter-for-loop-defer

Conversation

@rauljordan
Copy link
Copy Markdown
Contributor

Resolves NIT-4439

A common pitfall in Go development are bugs arising from defer invocations in for loops, which we are best avoiding. This adds a linter with tests

@rauljordan rauljordan enabled auto-merge April 8, 2026 19:28
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 0% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.10%. Comparing base (976ea45) to head (f666318).
⚠️ Report is 43 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4616   +/-   ##
=======================================
  Coverage   34.09%   34.10%           
=======================================
  Files         497      498    +1     
  Lines       59155    59194   +39     
=======================================
+ Hits        20169    20188   +19     
- Misses      35434    35463   +29     
+ Partials     3552     3543    -9     

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

❌ 11 Tests Failed:

Tests completed Failed Passed Skipped
4748 11 4737 0
View the top 3 failed tests by shortest run time
TestAliasingFlaky
Stack Traces | -0.000s run time
=== RUN   TestAliasingFlaky
=== PAUSE TestAliasingFlaky
=== CONT  TestAliasingFlaky
    common_test.go:777: BuildL1 deployConfig: DeployBold=true, DeployReferenceDAContracts=false
INFO [04-08|20:24:46.578] Starting peer-to-peer node               instance=test-stack-name/linux-amd64/go1.25.8
WARN [04-08|20:24:46.578] P2P server will be useless, neither dialing nor listening
INFO [04-08|20:24:46.579] Submitted contract creation              hash=0x399184f9977f0f6ea1e1f807698efdd88b4fcbb85106214486ecbfdf28b60683 from=0x57Ff0F473737a1c161bfF9efDF016F7991585088 nonce=0  contract=0xA46C59ce2FCaF445F96f66F0411e06A94D34BF45 value=0
WARN [04-08|20:24:46.580] Served eth_getTransactionReceipt         reqid=7 duration="30.928µs" err="transaction indexing is in progress" errdata="\"transaction indexing is in progress\""
INFO [04-08|20:24:46.580] Starting work on payload                 id=0x03486db7e7dc4073
INFO [04-08|20:24:46.580] New local node record                    seq=1,775,679,886,580 id=168376716c3f8def                        ip=127.0.0.1 udp=0 tcp=0
INFO [04-08|20:24:46.580] Started P2P networking                   self=enode://aad074ed4991ca4e36d5ec675eba345a6b56b9ae99e1aa076297f76b2224ca117390ad2d08505199942f23fdb1330de68223e0ce2e529270d475433000ce4367@127.0.0.1:0
WARN [04-08|20:24:46.580] Getting file info                        dir= error="stat : no such file or directory"
TestPruningDBSizeReduction
Stack Traces | 0.000s run time
=== RUN   TestPruningDBSizeReduction
--- FAIL: TestPruningDBSizeReduction (0.00s)
TestBatchPosterL1SurplusMatchesBatchGasFlaky
Stack Traces | 0.550s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x20f3452]

goroutine 23 [running]:
testing.tRunner.func1.2({0x3866aa0, 0x62fc9b0})
	/opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1872 +0x237
testing.tRunner.func1()
	/opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1875 +0x35b
panic({0x3866aa0?, 0x62fc9b0?})
	/opt/hostedtoolcache/go/1.25.8/x64/src/runtime/panic.go:783 +0x132
github.com/offchainlabs/nitro/arbnode.(*InboxTracker).GetBatchCount(0x17171900?)
	/home/runner/work/nitro/nitro/arbnode/inbox_tracker.go:210 +0x12
github.com/offchainlabs/nitro/arbnode.(*InboxTracker).FindInboxBatchContainingMessage(0x0, 0x6)
	/home/runner/work/nitro/nitro/arbnode/inbox_tracker.go:225 +0x2f
github.com/offchainlabs/nitro/system_tests.TestBatchPosterL1SurplusMatchesBatchGasFlaky(0xc000400fc0)
	/home/runner/work/nitro/nitro/system_tests/batch_poster_test.go:839 +0x725
testing.tRunner(0xc000400fc0, 0x4242560)
	/opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1934 +0xea
created by testing.(*T).Run in goroutine 1
	/opt/hostedtoolcache/go/1.25.8/x64/src/testing/testing.go:1997 +0x465

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

@gligneul gligneul assigned eljobe and unassigned gligneul Apr 9, 2026
@rauljordan rauljordan added this pull request to the merge queue Apr 10, 2026
Merged via the queue into master with commit e65384b Apr 10, 2026
27 checks passed
@rauljordan rauljordan deleted the raul/linter-for-loop-defer branch April 10, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants