[chore] enable revive deep-exit linter rule#8274
Conversation
Enable the `deep-exit` revive rule which flags calls to os.Exit / log.Fatal outside of main() or init() functions. Violations found and fixed: - examples/hotrod/cmd/root.go: remove dead os.Exit(-1) after logger.Fatal (zap already calls os.Exit(1) internally) - internal/storage/v1/badger/spanstore/read_write_test.go: replace log.Fatal with b.Fatal in two benchmark functions so failures are reported through the testing framework rather than aborting the process; drop now-unused "log" import Part of jaegertracing#5506 Signed-off-by: abhay1999 <abhaychaurasiya19@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR enables the deep-exit revive linter rule, which flags calls to os.Exit and log.Fatal outside of main() or init() functions. The PR fixes all 5 violations by removing dead code and replacing log.Fatal with appropriate alternatives.
Changes:
- Removed dead
os.Exit(-1)call afterlogger.Fatal()inexamples/hotrod/cmd/root.goand its unusedosimport - Replaced 4
log.Fatalcalls withb.Fatalin benchmark functions ininternal/storage/v1/badger/spanstore/read_write_test.goand removed the unusedlogimport - Enabled the
deep-exitrevive rule in.golangci.ymlby removing itsdisabled: trueentry
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
examples/hotrod/cmd/root.go |
Removed unreachable os.Exit(-1) call and unused os import |
internal/storage/v1/badger/spanstore/read_write_test.go |
Replaced log.Fatal with b.Fatal in benchmark functions for proper test framework integration and removed unused log import |
.golangci.yml |
Enabled deep-exit revive rule |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8274 +/- ##
==========================================
+ Coverage 96.56% 96.59% +0.02%
==========================================
Files 332 332
Lines 17575 17575
==========================================
+ Hits 16972 16976 +4
+ Misses 454 451 -3
+ Partials 149 148 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Mahad Zaryab <43658574+mahadzaryab1@users.noreply.github.com>
Signed-off-by: Victor Chidera Obiezue <obiezuechidera@gmail.com>
Summary
Enables the
deep-exitrevive rule, which flags calls toos.Exit/log.Fataloutside ofmain()orinit()functions.Only 5 violations, all straightforward fixes:
examples/hotrod/cmd/root.go— removed deados.Exit(-1)that appeared right afterlogger.Fatal(...). Zap'sFatalalready callsos.Exit(1)internally, so the explicit exit was unreachable code.internal/storage/v1/badger/spanstore/read_write_test.go— replaced 4log.Fatalcalls withb.FatalinBenchmarkWritesandmakeReadBenchmark. Both closures capture the outerb *testing.B, so this is a direct drop-in. It's also a real improvement —log.Fatalcallsos.Exitand skips deferred teardown, whileb.Fatalcooperates with the testing framework. Dropped the now-unused"log"import.Part of #5506.
Test plan
golangci-lint runpasses with zero issuesgo build ./examples/hotrod/...andgo build ./internal/storage/v1/badger/...succeed