mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Add static analyzer to discourage use of panic() (#15075)
* Implement static analysis to prevent panics * Add nopanic to nogo * Fix violations and add exclusions Fix violations and add exclusions for all * Changelog fragment * Use pass.Report instead of pass.Reportf * Remove strings.ToLower for checking init method name * Add exclusion for herumi init * Move api/client/beacon template function to init and its own file * Fix nopanic testcase
This commit is contained in:
@@ -69,7 +69,7 @@ func main() {
|
||||
case "fluentd":
|
||||
f := joonix.NewFormatter()
|
||||
if err := joonix.DisableTimestampFormat(f); err != nil {
|
||||
panic(err)
|
||||
panic(err) // lint:nopanic -- This shouldn't happen, but crashing immediately at startup is OK.
|
||||
}
|
||||
logrus.SetFormatter(f)
|
||||
case "json":
|
||||
@@ -94,7 +94,7 @@ func main() {
|
||||
defer func() {
|
||||
if x := recover(); x != nil {
|
||||
log.Errorf("Runtime panic: %v\n%v", x, string(runtimeDebug.Stack()))
|
||||
panic(x)
|
||||
panic(x) // lint:nopanic -- This is just resurfacing the original panic.
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user